- This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Ok, so I am learning PHP and having trouble with some basic code. I have a text box with a submit button to enter an email address for a mailing list. I want the the code to check to see if anything has been filled out and if so enter it into the database, at the same time check to see if that email address has already been submitted. The code I have written just keeps adding new email addresses even if the field is blank, what am I doing wrong? I have supplied the code below:
mysql_query(“INSERT INTO users (email)
VALUES (‘$email’)”);
echo “Success!”;
} else {
echo “Please enter a valid email address.”;
}
?>
*This part of the code provided is supposed to check if the field is blank
Maybe this will help?
to check if it’s blank, just do:
$email = mysql_real_escape_string($_POST);
if ($email) {
*Rest of code*
} else {
echo 'Please fill all fields';
}
?>
That worked cyneWATCH, thanks for that. Why would taking the isset out make it work? I kinda figured that adding an isset would test wether is was there or not like a boolean?
stevendeeds, thanks for that link I am def. gonna go through that one…