p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: sending form as email


Message #1 by "Dominic Savio" <kselvanathan@y...> on Wed, 25 Sep 2002 09:14:34
Hello,

I have trying to send a form and its details as an email to a site I have
created. I have written a code that will test if a particular field has
been left empty. If so it will ask the client to go back and fill it. And
that is the problem. The code is given below. The names with $ sign in
front are text boxes from the previous page. The code below is in a
different page to the one with the form.
<?php
if ((empty($1stname)
 OR (empty($surname)
 OR (empty($spouse1st)
 OR (empty($spousesur))
 {
  echo "One of the fields marked with the asterix has not been filled.\n";
  echo "Please click on the back button on the browser to enter the details."
 }
else
{
$mail_to ="kselvanathan@y...";
$mail_subject = "New!";
$mail_body = "First name: $1stname;\n";
$mail_body .= "$surname;\n";
$mail_body .= "$spouse1st;\n";
$mail_body .= "$spousesur;\n";
if(mail($mail_to, $mail_subject, $mail_body))
            echo "Successfully sent the e-mail \"$mail_subject\" to $mail_to.";
else echo "Failed to send the e-mail \"$mail_subject\"."
}
?>

Thanks for your help
Selva

  Return to Index