Here i'm trying to send a contact form values to email id. I've posted contact.php page code. I've done server side validation on same page. After validation successfully completed it should redirect to email.php page. How should i do?
Contact.php
<?php
$errname = "";
$errmotorcycle = "";
//some codes
if($_POST["contacts"] == "all")
{
// name validation
if(empty($_POST["name"]))
{
$errname = '<span class="error">Should not be empty</span>';
}
else if(preg_match("/^[a-zA-Z ]+$/", $_POST["name"]) === 0)
{
$errname = '<span class="error">Name must be from letters and spaces only</span>';
}
else
{
$errname = '';
}
// motorcycle validation
if($_POST["typeofmotor"] == "empty")
{
$errmotorcycle = '<span class="error">You must select one option</span>';
}
//some codes
}
?>
<html>
<head><title></title></head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" >
<input type="hidden" name="contacts" value="all" />
<table width="980" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="281" height="40" class="rightalign">Name : </td>
<td width="268"><input type="text" name="name" class="normal" value="<?php $_POST['name']; ?>" /></td>
<td width="431" valign="middle"><?php if(isset($errname)) echo $errname; ?></td>
</tr>
//some codes
</table>
</form>
</body>
</html>