Use javascript to validate. This way the form is not submitted in the first
place. You could use some server-side (PHP) validation "just in case".
<html>
<head>
<title>mail send</title>
<Script Language="JavaScript">
function validate()
{
jumpto = "";
errors = "";
var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
var reg2str =
"^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
var reg1 = new RegExp(reg1str);
var reg2 = new RegExp(reg2str);
if (document.emailer.name.value == "") {
errors += 'Please enter a Name:\n';
if (!jumpto) {
jumpto = document.emailer.name;
}
}
if (reg1.test(document.emailer.mail.value) ||
!reg2.test(document.forms[0].mail.value)) {
errors += 'Please use a valid Email Address:\n';
if (!jumpto) {
jumpto = document.emailer.mail;
}
}
if (errors) {
string = "The following fields were incomplete or invalid.
Please
complete them to continue.\n\n"+errors;
alert(string);
jumpto.focus();
return false;
}
else {
return true;
}
}
</SCRIPT>
</head>
<body bgcolor="#FFFFFF">
<form name="emailer" action="<?php echo($PHP_SELF); ?>" method=post
onSubmit='return validate()'>
for: <input size="26" name="for"><br>
your name: <input size="26" name="name"><br>
your email: <input size="26" name="mail"><br>
text:<br>
<textarea name="texto" rows="8" cols="20"></textarea><br>
<input type="submit" name="submit" value="enviar">
</form>
<?php
$subjet = "Welcome home [ www.lamundial.net ]";
$headers = "From: " . $name . " <" . $mail . ">";
$headers .= "\nContent-Type: text/html; charset=iso-8859-1\n";
$headers .= "X-Mailer: PHP\n";
if ($submit) {
mail("$for", "$subjet", "$text", "$headers");
}
?>
</body>
</html>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]