I am having a problem with a newsletter subscription I am writing. The problem is I don't seem to be getting any errors or in fact anything at all when someone clicks submit, all that happens is they are presented with a blank white page and nothing more, so its difficult to diagnose.
Basically the policy reminder form has a field on it called newslettersubscribe, if this is equal to yes the user is also subscribed to the newsletter list as well as the policy reminder list they are signing up for. I am not 100% sure if I am using the real_escape_string functions correctly though or not ?.
<?php
$email = real_escape_string($_POST['email']);
$name = real_escape_string($_POST['name']);
$newslettersubscribe = real_escape_string($_POST['newslettersubscribe']);
if ($newslettersubscribe == 'no'){
}
else{
mysql_query("INSERT INTO ymeg_chronoforms_data_NewsletterDesigner (email, name)
VALUES ('$email', '$name')") or die(mysql_error());
}
?>
EDIT >>>>>>>>>>>>>>>>>>>
If I remove the real escape string I get the error
Unknown column 'email' in 'field list'
when hitting submit, so that probably explains the white page, what does the above error mean ?.
EDIT 2 >>>>>>>>>>>>>>>>>
This is a sample record from the database im trying to connect to :
cf_id 6
cf_uid 5f04f21f80a596f17341cec92a48b197
cf_created 2012-06-01 10:13:16
cf_modified
cf_ipaddress 217.154.186.84
cf_user_id 44
name Iain Simpson
email [email protected]
Try echoing values to make sure it isn't an issue with simply defaulting to
$newslettersubscribe = 'no';
You would need to do something simple like the following:
$email = real_escape_string($_POST['email']);
$name = real_escape_string($_POST['name']);
$newslettersubscribe = real_escape_string($_POST['newslettersubscribe']);
echo $email.' | '.$name.' | '.$newslettersubscribe;
exit();
That should at least show you what your values are for the required variables. Its all about simply troubleshooting what is coming in, and how it impacts your sql query.