I searched the forum for this issue to no avail, hopefully this isn't a repeat:
I'm doing a very simple form to get mail. I just want three slots, one for someone's name, one for an email address, and one for their comments. I also want the email address and comments section to be mandatory. If I use this:
Code: Select all
$yourname = validation($_POST['yourname']);
$comments = validation($_POST['comments'], "Comment Required");
$email = validation($_POST['email'], "Email Address Required");Code: Select all
<?php
function validation($data, $blank='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($blank && strlen($data) == 0)
{
die($blank);
}
return $data;
}
?>
It is, however, very ugly. I want instead to redirect to another page identical to the form page but with the required words in red. So I made another page entitled concacte.php, and replaced the ugly words with header('location') tags as follows:
Code: Select all
$yourname = validation($_POST['yourname']);
$comments = validation($_POST['comments'], header('Location: ../index.php?entry=contacte'));
$email = validation($_POST['email'], header('Location: ../index.php?entry=contacte'));
Thank you in advance,
Justin