kplantation Posted March 1, 2009 Share Posted March 1, 2009 I have a form that has an action to a PHP file with this code: <?php $EmailFrom = "matthewdipalma@gmail.com"; $EmailTo = "matthew0dipalma@gmail.com"; $Subject = "FORM"; $Name = Trim(stripslashes($_POST['Name'])); $Filename = Trim(stripslashes($_POST['Filename'])); $OtherInformation = Trim(stripslashes($_POST['OtherInformation'])); $validationOK=true; if (!$validationOK) { print "<meta http-equiv="refresh" content="0;URL=error.htm">"; exit; } $Body .= "Name: "; $Body .= $Name; $Body .= "n"; $Body .= "Filename: "; $Body .= $Filename; $Body .= "n"; $Body .= "OtherInformation: "; $Body .= $OtherInformation; $Body .= "n"; $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); if ($success){ print "<meta http-equiv="refresh" content="0;URL=ok.htm">"; } else{ print "<meta http-equiv="refresh" content="0;URL=error.htm">"; } I get this error upon testing: Parse error: syntax error, unexpected T_STRING in /www/110mb.com/k/p/l/a/n/t/a/t/kplantation/htdocs/upload/contact.php on line 12 What is wrong? Quote Link to comment https://forums.phpfreaks.com/topic/147379-easy-php-form-processing-error/ Share on other sites More sharing options...
kplantation Posted March 1, 2009 Author Share Posted March 1, 2009 <?php $EmailFrom = "matthewdipalma@gmail.com"; $EmailTo = "matthew0dipalma@gmail.com"; $Subject = "FORM"; $Name = Trim(stripslashes($_POST['Name'])); $Filename = Trim(stripslashes($_POST['Filename'])); $OtherInformation = Trim(stripslashes($_POST['OtherInformation'])); $validationOK=true; if (!$validationOK) { print "<meta http-equiv="refresh" content="0;URL=error.htm">"; exit; } $Body .= "Name: "; $Body .= $Name; $Body .= "n"; $Body .= "Filename: "; $Body .= $Filename; $Body .= "n"; $Body .= "OtherInformation: "; $Body .= $OtherInformation; $Body .= "n"; $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); if ($success){ print "<meta http-equiv="refresh" content="0;URL=ok.htm">"; } else{ print "<meta http-equiv="refresh" content="0;URL=error.htm">"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/147379-easy-php-form-processing-error/#findComment-773590 Share on other sites More sharing options...
Philip Posted March 1, 2009 Share Posted March 1, 2009 You need to make sure to escape the quotes, <?php $EmailFrom = "matthewdipalma@gmail.com"; $EmailTo = "matthew0dipalma@gmail.com"; $Subject = "FORM"; $Name = Trim(stripslashes($_POST['Name'])); $Filename = Trim(stripslashes($_POST['Filename'])); $OtherInformation = Trim(stripslashes($_POST['OtherInformation'])); $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } $Body .= "Name: "; $Body .= $Name; $Body .= "n"; $Body .= "Filename: "; $Body .= $Filename; $Body .= "n"; $Body .= "OtherInformation: "; $Body .= $OtherInformation; $Body .= "n"; $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> You could also do: <?php $EmailFrom = "matthewdipalma@gmail.com"; $EmailTo = "matthew0dipalma@gmail.com"; $Subject = "FORM"; $Name = Trim(stripslashes($_POST['Name'])); $Filename = Trim(stripslashes($_POST['Filename'])); $OtherInformation = Trim(stripslashes($_POST['OtherInformation'])); $validationOK=true; if (!$validationOK) { print '<meta http-equiv="refresh" content="0;URL=error.htm">'; exit; } $Body .= "Name: "; $Body .= $Name; $Body .= "n"; $Body .= "Filename: "; $Body .= $Filename; $Body .= "n"; $Body .= "OtherInformation: "; $Body .= $OtherInformation; $Body .= "n"; $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); if ($success){ print '<meta http-equiv="refresh" content="0;URL=ok.htm">'; } else{ print '<meta http-equiv="refresh" content="0;URL=error.htm">'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/147379-easy-php-form-processing-error/#findComment-773593 Share on other sites More sharing options...
kplantation Posted March 1, 2009 Author Share Posted March 1, 2009 Thanks! That worked, now I get this error though: Warning: mail() [function.mail] Safety Restriction is in effect. The mail() command is not allowed contact the admin in ... in line 30 Quote Link to comment https://forums.phpfreaks.com/topic/147379-easy-php-form-processing-error/#findComment-773601 Share on other sites More sharing options...
trq Posted March 1, 2009 Share Posted March 1, 2009 It means what it says, mail has been disabled on your server. Quote Link to comment https://forums.phpfreaks.com/topic/147379-easy-php-form-processing-error/#findComment-773611 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.