| Junior Member with 6 posts. THREAD STARTER | | Join Date: Sep 2011 Experience: Intermediate | |
Solved: PHP - if/then logic Hi all,
I'm new to the html and php coding club, so I'm learning as I go. I am developing a form on a php webpage, connecting to a MySQL database. Right now, I am working on the form validation (yes, I know everyone's favorite). Let me know what I am missing from the code below. Essentially, I am checking if fields are empty once the submit button is pushed. If any field is empty, the red html notice should appear, warning the user. If no field is empty on the pushed submit button, the form should be submitted successfully into the database. Yet, the code below does ABSOLUTELY NOTHING, regardless if I fill all fields or leave an empty field. Is it my IF logic? if (isset($_POST['Submitted']) AND
($_POST['date']==""
|| $_POST['state']==""
|| $_POST['county']=="")){
?>
<tr><td></td><td><center><font size="2" color="red" face="arial"> Please enter all fields of your input </font></center></td></tr>
<?php
}
if (isset($_POST['Submitted']) AND
$_POST['date']!==""
AND $_POST['state']!==""
AND $_POST['county']!=="")
{
$date=mysql_real_escape_string($_POST['date']);
$state=mysql_real_escape_string($_POST['state']);
$county=mysql_real_escape_string($_POST['county']); ... on to form submission into database with query and all
Any suggestions are much appreciated.
Thanks y'all! |