how to create missing fields message for a form
Posted: Sun Feb 02, 2003 2:19 pm
hi i have the following script:
<?php
if ($REQUEST_METHOD == "POST") {
$realname = strip_tags($realname);
$email = strip_tags($email);
$feedback = strip_tags($feedback);
$sendto = "jeroen_pfeil@hotmail.com";
$subject = "GroundX.nl Medewerkers Contact";
$message = "$realname, $email\n\n$feedback";
mail($sendto, $subject, $message);
}
?>
<html>
<head>
<title>contact</title>
<meta name="author" value="Jeroen Pfeil">
<meta name="contact">
</head>
<body bgcolor="#cccccc">
<div align="left">
<h2>Helpen op groundX.nl</h2>
<p><font size="2" face="Arial,Arial Narrow,Geneva,Swiss,SunSans-Regular">Wij zoeken naar medewerkers. Kun je overweg met phpp, html of grafische programma's en zou je best wel willen meehelpen aan deze site! stuur dan nu een berichtje!</font></p>
<font size="2" face="Courier New,Courier,Monaco">ps. voor re-previewers is het een pré om over goede nederlandse taalbeheersing te beschikken.</font></div>
<p>
<hr size=1 noshade></p>
<?
// if submitted form display sent message
if ($REQUEST_METHOD=="POST") {
echo("<P><b>je hebt dit verzonden:</b></p>\n");
echo("<blockquote><pre>\n");
echo("$message");
echo("</pre></blockquote>");
echo("<p><b>HEEL GRAPPIG...kappen nou!</b></p>\n");
}
// if not display form
else {
?>
<!-- *** START HTML FORM -->
<form action="<? echo("$script_name"); ?>" METHOD="POST">
<table cellpadding=4 cellspacing=0 border=0>
<tr><td><b>Naam: </b></td><td><input type="text" name="realname" size=25></td></tr>
<tr><td><b>Email:</b></td><td><input type="text" name="email" size=25></td></tr>
<tr><td colspan=2><b>over jezelf:</b><br>
<textarea name="feedback" rows=4 cols=40 wrap=physical></textarea>
</td></tr>
<tr><td colspan=2 align=right><input type="submit" value="verstuur"></td></tr>
</table>
</form>
<!-- *** END HTML FORM -->
<? } ?>
i need to know how to add a protection against not-filled fields, so if a field is missing that the mail wont be send and a message appears for the sender.
<?php
if ($REQUEST_METHOD == "POST") {
$realname = strip_tags($realname);
$email = strip_tags($email);
$feedback = strip_tags($feedback);
$sendto = "jeroen_pfeil@hotmail.com";
$subject = "GroundX.nl Medewerkers Contact";
$message = "$realname, $email\n\n$feedback";
mail($sendto, $subject, $message);
}
?>
<html>
<head>
<title>contact</title>
<meta name="author" value="Jeroen Pfeil">
<meta name="contact">
</head>
<body bgcolor="#cccccc">
<div align="left">
<h2>Helpen op groundX.nl</h2>
<p><font size="2" face="Arial,Arial Narrow,Geneva,Swiss,SunSans-Regular">Wij zoeken naar medewerkers. Kun je overweg met phpp, html of grafische programma's en zou je best wel willen meehelpen aan deze site! stuur dan nu een berichtje!</font></p>
<font size="2" face="Courier New,Courier,Monaco">ps. voor re-previewers is het een pré om over goede nederlandse taalbeheersing te beschikken.</font></div>
<p>
<hr size=1 noshade></p>
<?
// if submitted form display sent message
if ($REQUEST_METHOD=="POST") {
echo("<P><b>je hebt dit verzonden:</b></p>\n");
echo("<blockquote><pre>\n");
echo("$message");
echo("</pre></blockquote>");
echo("<p><b>HEEL GRAPPIG...kappen nou!</b></p>\n");
}
// if not display form
else {
?>
<!-- *** START HTML FORM -->
<form action="<? echo("$script_name"); ?>" METHOD="POST">
<table cellpadding=4 cellspacing=0 border=0>
<tr><td><b>Naam: </b></td><td><input type="text" name="realname" size=25></td></tr>
<tr><td><b>Email:</b></td><td><input type="text" name="email" size=25></td></tr>
<tr><td colspan=2><b>over jezelf:</b><br>
<textarea name="feedback" rows=4 cols=40 wrap=physical></textarea>
</td></tr>
<tr><td colspan=2 align=right><input type="submit" value="verstuur"></td></tr>
</table>
</form>
<!-- *** END HTML FORM -->
<? } ?>
i need to know how to add a protection against not-filled fields, so if a field is missing that the mail wont be send and a message appears for the sender.