richyunspoken Posted May 1, 2018 Share Posted May 1, 2018 (edited) Can anyone help, im setting up an email form and it is returning this error. **Parse error: syntax error, unexpected 'isInjected' (T_STRING), expecting '(' in /storage/ssd4/339/5596339/public_html/send_mail.php on line 21** **Html code:** <form action="send_mail.php" method="post"> <p><br> <input name="Name" type="text" style="width: 325px; height: 40px" placeholder="Your Name *" required><p> <input name="Email" type="text" style="width: 325px; height: 40px" placeholder="Email Address *" required><p> <input name="Telephone" type="text" style="width: 325px; height: 40px" placeholder="Telephone Number *" required><p> <select name="Type" style="width: 325px; height: 40px" required> <option value="" disabled selected>Type of Move * </option> <option value="Home Move Only">Home Move Only</option> <option value="Business Move Only">Business Move Only</option> <option value="Home Move and Storage">Home Move and Storage</option> <option value="Business Move and Storage">Business Move and Storage</option> <option value="General Move">General Move</option> </select><p> <input name="From" type="text" style="width: 325px; height: 40px" placeholder="Moving From (Postcode) *" required><p> <input name="To" type="text" style="width: 325px; height: 40px" placeholder="Moving To (Postcode) *" required><p> <button name="Abutton1" style="width: 325px; height: 40px;" class="btn1" type="submit" value="Submit">Submit </button> <p align="left"> <input name="Checkbox1" type="checkbox" required><span class="style7">I accepted.</span></form> **PHP Code** <?php $webmaster_email = "email@hotmail.co.uk"; $feedback_page = "feedback_form.html"; $error_page = "error_message.html"; $thankyou_page = "thank_you.html"; $Email = $_REQUEST['email'] ; $Telephone = $_REQUEST['Telephone'] ; $Name = $_REQUEST['Name'] ; $Type = $_REQUEST['Type'] ; $From = $_REQUEST['From'] ; $To = $_REQUEST['To'] ; $Checkbox1 = $_REQUEST['Checkbox1'] ; $msg = "Name: " . $Name . "\r\n" . "Email: " . $Email . "\r\n" . "Telephone: " . $Telephone . "\r\n" . "Type: " . $Type . "\r\n" . "From: " . $From . "\r\n" . "To: " . $To . "\r\n" . "Checkbox1: " . $Checkbox1 . "\r\n" . function isInjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } if (!isset($_REQUEST['Email'])) { header( "Location: $feedback_page" ); } elseif (empty($Name) || empty($Email)) { header( "Location: $error_page" ); } elseif (empty($Name) || empty($Email) || empty($Telephone) || empty($Type) || empty($From) || empty($To)) { header( "Location: $error_page" ); } else { mail( "$webmaster_email", "Feedback Form Results", $msg ); header( "Location: $thankyou_page" ); } ?> Please help this is driving me mad. Cheers Richard Edited May 1, 2018 by richyunspoken Quote Link to comment Share on other sites More sharing options...
Barand Posted May 1, 2018 Share Posted May 1, 2018 "Checkbox1: " . $Checkbox1 . "\r\n" . function isInjected($str) { | | concatenation operator You are trying to concatenate the function definition with your string. Quote Link to comment Share on other sites More sharing options...
richyunspoken Posted May 1, 2018 Author Share Posted May 1, 2018 Thank you Barand for your reply. How would i go about fixing this issue? Any help would be appreciated. I am still new to PHP and don't understand it all. Thank you. Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted May 1, 2018 Share Posted May 1, 2018 How would i go about fixing this issue? As Barand mentioned, the following statement needs to be closed before you define the isInjected() function: "Checkbox1: " . $Checkbox1 . "\r\n" . You just need to replace the concatenation character with a semi-colon. "Checkbox1: " . $Checkbox1 . "\r\n"; Quote Link to comment Share on other sites More sharing options...
ginerjm Posted May 2, 2018 Share Posted May 2, 2018 And stop using the global REQUEST array - use the one that matters in each case whether it be $_POST or $_GET And learn to place your functions outside the flow of your logic. Why interrupt your code with some extraneous block that is going to be used all over the place? Place functions at the end of your mainstream php code. And add a 'from' address to your (missing) headers argument of the mail call. It is required and is not usually included in the .ini file so you should be sure to add it here. Read the manual. Are confused now? Quote Link to comment 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.