Page 1 of 1

catching blank entries when a form is posted

Posted: Sun Aug 17, 2003 1:30 pm
by deane034
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

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))
&#123;
$errmsg = "Please enter an Alias name <BR> " ;
$blvalid = false ;
&#125;

if (!$amsg )
&#123;
$errmsg .= "Please enter your Problem <BR> " ;
$blvalid = false                                ;
&#125;

if ($clovedoc != "on" and $cgirl != "on" and $cguy !=  "on")
&#123;
$blvalid = false    ;
$errmsg .= "Please Choose a minimum one option for the quesiton 'Who Do you want to answer the Question ' " ;
&#125;

 if ($blvalid == true)
 &#123;

$mysub = "Advice for ".$talias ;
$body = $amsg                  ;

if ($clovedoc == "on" and $cgirl == "on" and $cguy == "on" )
&#123;
$toady = "lovedoc@lankanteens.cjb.net,gurls@lankanteens.cjb.net, guys@lankanteens.cjb.net " ;
&#125;

if($cgirl == "on" and $clovedoc == "on" )
&#123;
$toady = "lovedoc@lankanteens.cjb.net,gurls@lankanteens.cjb.net"  ;
&#125;

if ($cguy == "on" and $clovedoc == "on")
&#123;
$toady = "lovedoc@lankanteens.cjb.net,guys@lankanteens.cjb.net" ;
&#125;

if ($cgirl == "on" and $cguy == "on" )
&#123;
$toady = "gurls@lankanteens.cjb.net, guys@lankanteens.cjb.net " ;
&#125;

  mail($toady,$mysub, $body, "From: ".$talias);

  header("Location:thanku.htm") ;
  exit() ;
  &#125;
 ?>

 <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&nbsp; </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">&nbsp;</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>