Thanks [ form input checking problem ]
| From: | Aniceto Lopez | Date: | Fri, 13 Jul 2001 11:43:01 +0000 |
| Subject: | Thanks [ form input checking problem ] | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-57722@lists.php.net to get a copy of this message | ||
Thanks everyone helped me (Aaron Bennett specialy) with the
"input checking problem". Maybe Rip's idea of mixing javascript
and php is a good one but I'm newbie and I'm not sure which
languaje takes the control first or how the interact.
Anyway I'll work in that direction later
Hasta la proxima
Aniceto López
------------------------------------------------------------
here is the "form that sends a mail but chek if all the inputs
were filled in" in case anybody wants to use it
<html>
<head>
<title>mail send</title>
</head>
<body bgcolor="#FFFFFF">
<form name="emailer"action="<?php echo($PHP_SELF); ?>"
method="post">
For: <input size="26" name="for" value="<?= $for
?>"><br>
Your name: <input size="26" name="name" value="<?= $name
?>"><br>
Your email: <input size="26" name="mail" value="<?= $mail
?>"><br>
Subjet: <input size="26" name="subject" value="<?= $subject
?>"><br>
Text:<br> <textarea rows="8" cols="20" name="text"><?=
$text
?></textarea><br>
<input type="submit" name="submit" value="send">
</form>
<br>
<? if (isset($errmsg)) { ?> <?=$errmsg?><br> <? } ?>
<?php
$headers = "From: " . $name . " <" . $mail . ">";
$headers .= "\nContent-Type: text/html; charset=iso-8859-1\n";
$headers .= "X-Mailer: PHP\n";
if ($submit)
{
if ((!$for) || (!$name) || (!$mail) || (!$subject) || (!$text))
{
$submit = false;
if (!$for) { $errormsg = "Recipient email<br>"; }
if (!$name) { $errormsg .= "Your name<br>"; }
if (!$mail) { $errormsg .= "Your email<br>"; }
if (!$subject) { $errormsg .= "The subject<br>"; }
if (!$text) { $errormsg .= "Some text<br>"; }
print("<b>Following missed data</b><br>");
print($errormsg);
} else {
print("Mail sended!");
mail("$for", "$subject", "$text", "$headers");
}
}
?>
</body>
</html>