hi,
i’ve used the form off the tutorial section and i’m trying to add a validate on the email. i have the follow code but i’m not sure where to place it. if anyone can have a look through this and tell me what to do
function checkemail($first)
{
if
(ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&\'*+\\/0-9=?A-Z^_
`a-z{|}~]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $first))
return true;
else
return false;
}
this is the php code for the mailform
<?PHP
$to = "info@garethflavell.co.uk";
$subject = "Results from your Request Info form";
$headers = "From: Form Mailer";
$forward = 0;
$location = "";
$date = date ("l, F jS, Y");
$time = date ("h:i A");
$msg = "Below is the result of your feedback form. It was submitted on $date at $time.
";
if ($_SERVER['REQUEST_METHOD'] == "POST") {
foreach ($_POST as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "
";
}
}
else {
foreach ($_GET as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "
";
}
}
mail($to, $subject, $msg, $headers);
if ($forward == 1) {
header ("Location:$location");
}
else {
echo "Thank you for submitting our form.";
}
?>
and this is my html code
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=“Content-Type” content=“text/html; charset=iso-8859-1”>
<link href=“styles/midori.css” rel=“stylesheet” type=“text/css”>
</head>
<body leftmargin=“0” rightmargin=“0” bottommargin=“0” topmargin=“0”>
<table width=“369” height=“164” border=“0” cellpadding=“0” cellspacing=“0”>
<tr>
<td width=“24” height=“1”><img src=“images/spacer.gif” width=“24” height=“1”></td>
<td width=“345”><img src=“images/spacer.gif” width=“344” height=“1”></td>
</tr>
<tr>
<td height=“13” background=“images/hor.gif”><img src=“images/spacer.gif” width=“24” height=“13”></td>
<td bgcolor=“E8E8E8” class=“verdana10”>Contact</td>
</tr>
<tr>
<td rowspan=“2”> </td>
<td height=“7”><img src=“images/spacer.gif” width=“1” height=“7”></td>
</tr>
<tr>
<td height=“143”><table width=“344” height=“143” border=“0” cellpadding=“0” cellspacing=“0”>
<form action=“mailer.php” method=“post”>
<tr>
<td width=“70” height=“22” class=“form”>Name</td>
<td width=“117” align=“right”><input name=“test” type=“text” size=“14”></td>
<td width=“46” class=“form”>Email</td>
<td width=“111” align=“right”><input name=“email” type=“text” size=“15”></td>
</tr>
<tr>
<td height=“102” align=“left” valign=“top”><table width=“61” height=“38” border=“0” cellpadding=“0” cellspacing=“0”>
<tr>
<td width=“71” height=“22” class=“form”>Message</td>
</tr>
<tr>
<td height=“19”> </td>
</tr>
</table></td>
<td colspan=“3” align=“right”><textarea name=“message” cols=“31” rows=“5” wrap=“VIRTUAL”></textarea></td>
</tr>
<tr>
<td height=“19”> </td>
<td> </td>
<td> </td>
<td align=“right”><input name=“submit” type=“image” id=“submit” src=“images/submit.gif” width=“38” height=“16” border=“0”></td>
</tr>
</form>
</table></td>
</tr>
</table>
</body>
</html>
any help is much appricated