ornclo Posted February 3, 2009 Share Posted February 3, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/143568-solved-simple-error/ Share on other sites More sharing options...
Philip Posted February 3, 2009 Share Posted February 3, 2009 It's giving you an error, because you are trying to continue (concatenating) the variable (with use of .=) when the variable doesn't exist beforehand. Change: // prepare email body text $Body .= "\n"; to: // prepare email body text $Body = "\n"; Quote Link to comment https://forums.phpfreaks.com/topic/143568-solved-simple-error/#findComment-753307 Share on other sites More sharing options...
ornclo Posted February 3, 2009 Author Share Posted February 3, 2009 :D Thank you so very much. It worked. I'm still learning about the PHP thing. Again, thank you. {cookie}{Gift Card:Chili's} Quote Link to comment https://forums.phpfreaks.com/topic/143568-solved-simple-error/#findComment-753310 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.