catching blank entries when a form is posted
Posted: Sun Aug 17, 2003 1:30 pm
hi guys im having this wired problem, i am a real new to PHP but i have done some programming.. i am creating a small.. email form .. but i want to eliminate blank entries.. but i cant seem to get it right? can u guys help me out
this is the code i am using for da.. PHP script... the HTML FORm is inlcuded
this is the code i am using for da.. PHP script... the HTML FORm is inlcuded
Code: Select all
<?php
/*
The Variables
Alias text box - talias
Check boxes - clovedoc, cgirl, cguy
Text area - amsg
*/
$blvalid = true ;
$talias = trim($talias) ;
if (empty($talias))
{
$errmsg = "Please enter an Alias name <BR> " ;
$blvalid = false ;
}
if (!$amsg )
{
$errmsg .= "Please enter your Problem <BR> " ;
$blvalid = false ;
}
if ($clovedoc != "on" and $cgirl != "on" and $cguy != "on")
{
$blvalid = false ;
$errmsg .= "Please Choose a minimum one option for the quesiton 'Who Do you want to answer the Question ' " ;
}
if ($blvalid == true)
{
$mysub = "Advice for ".$talias ;
$body = $amsg ;
if ($clovedoc == "on" and $cgirl == "on" and $cguy == "on" )
{
$toady = "lovedoc@lankanteens.cjb.net,gurls@lankanteens.cjb.net, guys@lankanteens.cjb.net " ;
}
if($cgirl == "on" and $clovedoc == "on" )
{
$toady = "lovedoc@lankanteens.cjb.net,gurls@lankanteens.cjb.net" ;
}
if ($cguy == "on" and $clovedoc == "on")
{
$toady = "lovedoc@lankanteens.cjb.net,guys@lankanteens.cjb.net" ;
}
if ($cgirl == "on" and $cguy == "on" )
{
$toady = "gurls@lankanteens.cjb.net, guys@lankanteens.cjb.net " ;
}
mail($toady,$mysub, $body, "From: ".$talias);
header("Location:thanku.htm") ;
exit() ;
}
?>
<HTML>
<HEAD>
<meta http-equiv="Content-Language" content="en-us">
<TITLE>Advice Central </TITLE>
</HEAD>
<BODY>
<p> <font face="Tahoma" color="#FF0000" size= "2"> There Were Error(s) submitting
your Advice Form: </font>
<p> <b> <font face= "Tahoma" size= "2"> <?php echo($errmsg) ; ?> </font> </b>
<p> <font face= "Tahoma" size= "2"> Please click <a href= "advice.htm">HERE</a> to
return to the form </font>
</BODY>
</HTML>
this is for the Form
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Alias</title>
</head>
<body>
<form action="advcmail.php" method="POST">
</font> <font face="Tahoma" size="2">Alias: </font>
<input type="text" name="talias" size="20" value=""> </font> </p>
<p> <font face="Tahoma"> <input type="checkbox" name="clovedoc" value="ON" > <font size="2">Love Doctor </font>
<input type="checkbox" name="cgirl" value="ON" ><font size="2">A Girl </font>
<input type="checkbox" name="cguy" value="ON" ><font size="2"> A Guy </font></font>
<p><font face="Tahoma" size="2">Poblem : </font>
<p><font face="Tahoma"><font size="2"> </font><textarea rows="5" name="amsg" cols="65"></textarea></font></p>
<p><font face="Tahoma"><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></font></p>
</form>
</body>
</html>