October 18, 200916 yr on the contact form, syntax error, unexpected T_CONSTANT_ENCAPSED_STRING on line 20 <?php $email = $_REQUEST['phone'] ; $message = $_REQUEST['enquiry'] ; $name = $_REQUEST['name']; if (!isset($_REQUEST['phone'])) { header( "Location: http://www.garethgillman.co.uk/contact.php" ); } elseif (empty($phone) || empty($enquiry) || empty($name)) { header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" ); header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" ); header( "Cache-Control: no-cache, must-revalidate" ); header( "Pragma: no-cache" ); } else { mail( "info@sglettings.co.uk", "Contact Form Results", "Name:" .$name. "<br />" "Contact No:" .$phone. "<br />" "Enquiry:" .$enquiry. ); header( "Location: index.php" ); } ?> It's within the mail section at the bottom, I have no idea how to solve PHP errors
October 18, 200916 yr You're not concatenating the strings properly - you're forgetting to add a . between lines, and you have an extra . before the closing ). You should have either: mail( "info@sglettings.co.uk", "Contact Form Results", "Name:" .$name. "<br />" . "Contact No:" .$phone. "<br />" . "Enquiry:" .$enquiry ); (note the extra . after the "<br />" on each line), or reduce the number of concatenations required with: mail( "info@sglettings.co.uk", "Contact Form Results", "Name:" .$name. "<br />Contact No:" .$phone. "<br />Enquiry:" .$enquiry ); You can also insert variables directly into the strings in PHP, without doing explicit concatenation, like this: mail( "info@sglettings.co.uk", "Contact Form Results", "Name: $name<br />Contact No: $phone<br />Enquiry: $enquiry"); Hope that helps!
October 18, 200916 yr Author You're not concatenating the strings properly - you're forgetting to add a . between lines, and you have an extra . before the closing ). You should have either: mail( "info@sglettings.co.uk", "Contact Form Results", "Name:" .$name. "<br />" . "Contact No:" .$phone. "<br />" . "Enquiry:" .$enquiry ); (note the extra . after the "<br />" on each line), or reduce the number of concatenations required with: mail( "info@sglettings.co.uk", "Contact Form Results", "Name:" .$name. "<br />Contact No:" .$phone. "<br />Enquiry:" .$enquiry ); You can also insert variables directly into the strings in PHP, without doing explicit concatenation, like this: mail( "info@sglettings.co.uk", "Contact Form Results", "Name: $name<br />Contact No: $phone<br />Enquiry: $enquiry"); Hope that helps! Worked a little, but now just get a white page .... The same contact form works fine on another site I did
October 18, 200916 yr Worked a little, but now just get a white page .... The same contact form works fine on another site I did Hi, I have totally rewritten your code and tested it. <?php header("Expires: Mon, 20 Dec 1998 01:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); $message = $_REQUEST["enquiry"]; $name = $_REQUEST["name"]; $phone = $_REQUEST["phone"]; $email = $_REQUEST["email"]; // optional $contents = <<<EOD Name: $name Phone: $phone Message: $message EOD; if (empty($phone) || empty($message) || empty($name)) { header("Location: http://www.garethgillman.co.uk/contact.php"); } else { if(!isset($email)) { $email = "webform@sglettings.co.uk"; } $headers = "From: $name <$email>\r\n" . "Reply-To: $email\r\n"; if(mail("info@sglettings.co.uk", "Contact Form Results", $contents, $headers)) { header("Location: /sent.php"); exit; } else { header("Location: /error.php"); exit; } } ?> Any issues let me know, Kyle Edited October 18, 200916 yr by Kyle Hudson MCP CCNA CIW
Create an account or sign in to comment