Jump to content

Recommended Posts

My form works correct, and submits correctly.

 

However, when I do submit the form, I always get an error on "Line 73" of my php code, but then it goes to the "ok.html" and sends the email.

 

If anyone could possible give me any advice, that would be fantab-ulistic.

 

Here is my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
   
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  
  <title>Emailing Form Data</title>
  
</head>

<body>

<?php 
   
  ini_set ("display_errors", "1");
  error_reporting(E_ALL);

  //declaration of variables

  $EmailFrom = trim(stripslashes($_POST['EmailFrom'])); 
  $EmailTo =   "patty@womenunitedministries.org";
  $Subject =   "Women United Contact";
  
  $Name =     trim(stripslashes($_POST['name']));
  $Address =  trim(stripslashes($_POST['address']));
  $City =     trim(stripslashes($_POST['city']));
  $State =    trim(stripslashes($_POST['state']));
  $Phone1 =   trim(stripslashes($_POST['phone1']));
  $Phone2 =   trim(stripslashes($_POST['phone2']));
  $Phone3 =   trim(stripslashes($_POST['phone3']));
  
  foreach ($_POST['visit'] as $value) {
   $Church =   trim(stripslashes($value));
  }
  
  foreach ($_POST['hear'] as $hear) {
   $About =    trim(stripslashes($hear));
  }
  
  foreach ($_POST['help'] as $help) { 
   $Ask =      trim(stripslashes($help));
  }
  
  $Comments = trim(stripslashes($_POST['comments'])); 


  // validation

  $validationOK=true;

   if (($EmailFrom)=="") $validationOK=false;
   if (($Name)=="")      $validationOK=false;
   if (($Address)=="")   $validationOK=false;
   if (($City)=="")      $validationOK=false;
   if (($State)=="" )    $validationOK=false;
   if (($Phone1)=="")    $validationOK=false;
   if (($Phone2)=="")    $validationOK=false;
   if (($Phone3)=="")    $validationOK=false;
    
   if (($Comments)=="")  $validationOK=false;
   
   if (!$validationOK) {
    print "<meta http-equiv=\"refresh\" content=\"0;URL=WUerror.html\">";
    exit;
   }


   // prepare email body text

   $Body .= "\n";
   $Body .= "Name: ";
   $Body .= $Name;
   $Body .= "\n";
   $Body .= "Address: ";
   $Body .= $Address;
   $Body .= "\n";
   $Body .= "City: ";
   $Body .= $City;
   $Body .= "\n";
   $Body .= "State: ";
   $Body .= $State;
   $Body .= "\n";
   $Body .= "Phone: ";
   $Body .= $Phone1;
   $Body .= "-";
   $Body .= $Phone2;
   $Body .= "-";
   $Body .= $Phone3;
   $Body .= "\n";
   $Body .= "Attended Church of God?: ";
   $Body .= $Church;
   $Body .= "\n";
   $Body .= "How did they hear about us?: ";
   $Body .= $About;
   $Body .= "\n";
   $Body .= "What would you like us to do for you?: ";
   $Body .= $Ask;
   $Body .= "\n";
   $Body .= "Comments: ";
   $Body .= $Comments;
   $Body .= "\n";


   // send email 

   $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");


   // redirect to success page 

   if ($success){
    print "<meta http-equiv=\"refresh\" content=\"0;URL=WUok.html\">"; 
   }
   else{
    print "<meta http-equiv=\"refresh\" content=\"0;URL=WUerror.html\">";
   }

  ?>

</body>

</html>

 

The line that is having the issue is this line:

$Body .= "\n";

 

No matter what I do - even if I take it out, or just put " " there, it still reads an error.

 

Any suggestions would be helpful.

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/143568-solved-simple-error/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.