Hi guys
Im running a form where user enters their details and click submit,
I thought i had created a if statement to check if the fields have been filled in.
however the error message do not kick in and passes blank info into the database................
here is the code:
any hints given will be great
if(isset($_POST["submit"]))
{
// Info has been submitted, check it:
if(!empty($messages))
{
displayErrors($messages);// Check login, password and password2 are not empty:
}
if(empty($messages))
{
// registration ok, get user id and update db with new info:
newUser($_POST["name"], $_POST["password"], $_POST["age"] );
}
if(strcmp($_POST["email"], $_POST["email2"]))
{
// The password and confirmation password didn't match,
// Add a message to be displayed to the user:
$messages[]="Your passwords did not match";
}
#field_validator($field_descr, $field_data, $field_type, $min_length="", $max_length="", $field_required=1)
field_validator("name", $_POST["name"], "alphanumeric", 4, 30);
field_validator("email", $_POST["email"], "string", 4, 30);
field_validator("confirm email", $_POST["email2"], "string", 4, 30);
field_validator("age", $_POST["age"], "string", 1, 3);
$query="SELECT guestbook2k FROM users WHERE name='".$_POST["name"]."'";
$result=mysql_query($query, $link) or die("MySQL query $query failed. Error if any: ".mysql_error());
}
print paragraph(submit_field("submit","Submit Survey"), reset_field());
//end the survey form.
print end_form();