Home › Forums › Back End › Empty Form Field Validation? › Reply To: Empty Form Field Validation?
January 12, 2014 at 9:18 am
#160169
Participant
I’ve followed a tutorial and every field validates independently. The problem now is I cannot get the insert statements to execute. This is the last field and the returns the data :
if (empty($_POST["email"]))
{$emailErr = "Enter your email address";}
else
{$email = validate_input($_POST["email"]);}
}
function validate_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
How do I then combine the above with this? Do I need the redirects?
$Link = mysql_connect($Host, $User, $Password);
$Query = "INSERT INTO $Table_2 VALUES ('0','".mysql_escape_string('forename')."','".mysql_escape_string("surname")."', '".mysql_escape_string("username")."', '".mysql_escape_string("password")."', '".mysql_escape_string("email")."')";
if(mysql_db_query ($DBName, $Query, $Link)){
$message = "You have successfully registered";
header("Location: register2.php?message=$message");
}else{
$message = "You've Broke It!";
die(mysql_error());
header("Location: register2.php?message=$message");
}
?>
This gives a redirect loop error.
Here’s the gist.