Hey Guys, I am finishing a contact form and I get this error when I go to submit: Parse error: syntax error, unexpected ':' in /var/www/vhosts/sparksolutions.net/httpdocs/contact.php on line 69 Here is the entire code for the form on www.sparksolutions.net/support.html <?php // get posted data into local variables $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $EmailTo = "Support@SparkSolutions.net"; $Subject = "Support Form Request"; $Name = Trim(stripslashes($_POST['Name'])); $Telephone = Trim(stripslashes($_POST['Telephone'])); $Email = Trim(stripslashes($_POST['Email'])); $Company = Trim(stripslashes($_POST['Company'])); $Website = Trim(stripslashes($_POST['Website'])); $WebDesignandDevelopment = Trim(stripslashes($_POST['WebDesignandDevelopment'])); $Ecommerce = Trim(stripslashes($_POST['Ecommerce'])); $SearchEngineOptimization = Trim(stripslashes($_POST['SearchEngineOptimization'])); $Other = Trim(stripslashes($_POST['Other'])); $Description = Trim(stripslashes($_POST['Description'])); $Budget = Trim(stripslashes($_POST['Budget'])); $AdditionalCommentsandQuestions = Trim(stripslashes($_POST['AdditionalCommentsandQuestions'])); // validation $validationOK=true; if (Trim($EmailFrom)=="") $validationOK=false; if (Trim($Name)=="") $validationOK=false; if (Trim($Telephone)=="") $validationOK=false; if (Trim($Email)=="") $validationOK=false; if (!$validationOK) { print "meta http-equiv=\"refresh\" content=\"0;URL=http://www.sparksolutions.net/support_error.html"; } // prepare email body text $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Telephone: "; $Body .= $Telephone; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Company: "; $Body .= $Company; $Body .= "\n"; $Body .= "Website: "; $Body .= $Website; $Body .= "\n"; $Body .= "WebDesignandDevelopment: "; $Body .= $WebDesignandDevelopment; $Body .= "\n"; $Body .= "Ecommerce: "; $Body .= $Ecommerce; $Body .= "\n"; $Body .= "SearchEngineOptimization: "; $Body .= $SearchEngineOptimization; $Body .= "\n"; $Body .= "Other: "; $Body .= $Other; $Body .= "\n"; $Body .= "Description: "; $Body .= $Description; $Body .= "\n"; $Body .= "Budget: "; $Body .= $Budget; $Body .= "\n"; $Body .= "AdditionalCommentsandQuestions: "; $Body .= $AdditionalCommentsandQuestions; $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=http://www.sparksolutions.net/thank_you.html"; } else{ print "meta http-equiv=\"refresh\" content=\"0;URL=http://www.sparksolutions.net/support_error.html"; } ?> If anyone can help that would be great!!! Thanks, Nick
Change line 69: $success = mail($EmailTo, $Subject, $Body, "From: <".$EmailFrom.">"); PHP: or $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); PHP: Both should work. Edit: You maybe want to change your redirect to something like this: "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.sparksolutions.net/support_error.html\">"; PHP: or: http://de3.php.net/manual/en/function.header.php
Just one note, since you exposed the code and url where this form will live, I recommend that you sanitize $EmailFrom variable before calling mail() function. Hijackers can inject additional headers to the email message using new line \n and CC:, and send spam using your code.
for example add these 2 lines somewhere before calling mail() function: $EmailFrom = str_replace("\n","",$EmailFrom); $EmailFrom = str_replace("\r","",$EmailFrom); PHP: Or, maybe your question was how would I inject additional headers using your form?
lol @ Sergey wasn't it that IF and Else were supposed to look like: if($some_var) { // some code here } where's his brackets on all the If's ?!?!?!?!!?