andierue Posted October 15, 2012 Share Posted October 15, 2012 I am getting some errors on my PHP form --- first one is Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in /home/content/52/9922952/html/sg_contact… on line 38 and the other is Warning: Cannot modify header information - headers already sent by (output started at /home/content/52/9922952/html/sg_contact… in /home/content/52/9922952/html/sg_contact… on line 48 HERE IS MY ORIGINAL CODE FOR THE FILE---PLEASE HELP WITH THE CHANGES I NEED TO MAKE-- ______________________________________… <?php /* This PHP form mailing script created by SiteGrinder 3.1.2 s_239 http://www.medialab.com/sitegrinder3 */ function stripFormSlashes($arr) { if(!is_array($arr)) { return stripslashes($arr); } else { return array_map('stripFormSlashes', $arr); } } if(get_magic_quotes_gpc()) { $_POST = stripFormSlashes($_POST); } if(($_POST['email']=="")) { echo "<html><body><p>The following fields are <strong>required</strong>.</p><ul>"; if($_POST['email'] == ""){ echo "<li>*Email</li>"; } echo "</ul><p>Please use your browsers <a href=\"javascript:history.back();\">Back… button and fill out these fields.</p></body></html>"; } else { $message = ""; $message .= "Name: " . htmlspecialchars($_POST['name'], ENT_QUOTES) . "<br>\n"; $message .= "*Email: " . htmlspecialchars($_POST['email'], ENT_QUOTES) . "<br>\n"; $message .= "Inquiring: " . htmlspecialchars($_POST['inquiring'], ENT_QUOTES) . "<br>\n"; $message .= "Comments: " . htmlspecialchars($_POST['comments'], ENT_QUOTES) . "<br>\n"; $lowmsg = strtolower($message); $injection_strings = array ( "content-type:","charset=","mime-version… foreach($injection_strings as $suspect) { if(( preg_match($suspect, $lowmsg)) || ( preg_match($suspect, strtolower($_POST['name']))) || ( preg_match($suspect, strtolower($_POST['email'])))) { die ( 'Illegal Input. Go back and try again. Your message has not been sent.' ); } } $headers = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: \"" . $_POST['name'] . "\" <" . $_POST['email'] . ">\r\n"; $headers .= "Reply-To: " . $_POST['email'] . "\r\n"; $message = utf8_decode($message); mail("[email protected]", "Authentic Health Inquiry", $message, $headers); header("Location: http://www.authentichealthbykate/thank-you.html"); } ?> ______________________________________… THANK YOU VERY MUCH FOR YOUR TIME!!!!!!! contact_i51contact.php Link to comment https://forums.phpfreaks.com/topic/269495-errors-in-php-code-with-preg_match-functionpreg-match-and-cannot-modify-header-information/ Share on other sites More sharing options...
TOA Posted October 15, 2012 Share Posted October 15, 2012 $injection_strings = array ( "content-type:","charset=","mime-version… You don't close out your array properly. Fix that first, then check out this sticky for your header errors Link to comment https://forums.phpfreaks.com/topic/269495-errors-in-php-code-with-preg_match-functionpreg-match-and-cannot-modify-header-information/#findComment-1385348 Share on other sites More sharing options...
andierue Posted October 15, 2012 Author Share Posted October 15, 2012 what do i need to put in there to close it out? i'm sorry, very new at all this.. Link to comment https://forums.phpfreaks.com/topic/269495-errors-in-php-code-with-preg_match-functionpreg-match-and-cannot-modify-header-information/#findComment-1385349 Share on other sites More sharing options...
TOA Posted October 15, 2012 Share Posted October 15, 2012 remove the ... and change to "); $injection_strings = array ( "content-type:","charset=","mime-version"); Link to comment https://forums.phpfreaks.com/topic/269495-errors-in-php-code-with-preg_match-functionpreg-match-and-cannot-modify-header-information/#findComment-1385350 Share on other sites More sharing options...
andierue Posted October 15, 2012 Author Share Posted October 15, 2012 i don't know what it didn't show up on here, but in the actual code ( see attached file) it is closed out already $message = ""; $message .= "Name: " . htmlspecialchars($_POST['name'], ENT_QUOTES) . "<br>\n"; $message .= "*Email: " . htmlspecialchars($_POST['email'], ENT_QUOTES) . "<br>\n"; $message .= "Inquiring: " . htmlspecialchars($_POST['inquiring'], ENT_QUOTES) . "<br>\n"; $message .= "Comments: " . htmlspecialchars($_POST['comments'], ENT_QUOTES) . "<br>\n"; $lowmsg = strtolower($message); $injection_strings = array ( "content-type:","charset=","mime-version:","multipart/mixed","bcc:","cc:"); foreach($injection_strings as $suspect) { if(( preg_match($suspect, $lowmsg)) || ( preg_match($suspect, strtolower($_POST['name']))) || ( preg_match($suspect, strtolower($_POST['email'])))) { die ( 'Illegal Input. Go back and try again. Your message has not been sent.' ); } } $headers = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: \"" . $_POST['name'] . "\" <" . $_POST['email'] . ">\r\n"; $headers .= "Reply-To: " . $_POST['email'] . "\r\n"; $message = utf8_decode($message); mail("[email protected]", "Authentic Health Inquiry", $message, $headers); header("Location: http://www.authentichealthbykate/thank-you.html"); } ?> Link to comment https://forums.phpfreaks.com/topic/269495-errors-in-php-code-with-preg_match-functionpreg-match-and-cannot-modify-header-information/#findComment-1385353 Share on other sites More sharing options...
andierue Posted October 15, 2012 Author Share Posted October 15, 2012 and still giving me the errors: Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in /home/content/52/9922952/html/sg_contact_content/contact_i51contact.php on line 38 Link to comment https://forums.phpfreaks.com/topic/269495-errors-in-php-code-with-preg_match-functionpreg-match-and-cannot-modify-header-information/#findComment-1385354 Share on other sites More sharing options...
TOA Posted October 15, 2012 Share Posted October 15, 2012 preg requires delimiters, I don't see any in there. Look at the difference between these manual examples and yours. Link to comment https://forums.phpfreaks.com/topic/269495-errors-in-php-code-with-preg_match-functionpreg-match-and-cannot-modify-header-information/#findComment-1385356 Share on other sites More sharing options...
andierue Posted October 15, 2012 Author Share Posted October 15, 2012 thank you for all the responses, i am still having issues trying to figure out where to my delimiters, i am not really a php coding guy and unfamiliar with alot of the language. Basically i have this form for my client at http://authentichealthbykate.com/contact.html and it is supposed to go to a thank you page when you submit the form --- http://authentichealthbykate.com/thank-you.html whenever i submit the form, the email sends, but i get all the errors on the next page --- Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in /home/content/52/9922952/html/sg_contact… on line 38 Warning: Cannot modify header information - headers already sent by (output started at /home/content/52/9922952/html/sg_contact… in /home/content/52/9922952/html/sg_contact… on line 48 i am just trying to figure out how to send the message, have no issues and get it to go to the thank you page. Link to comment https://forums.phpfreaks.com/topic/269495-errors-in-php-code-with-preg_match-functionpreg-match-and-cannot-modify-header-information/#findComment-1385358 Share on other sites More sharing options...
Jessica Posted October 15, 2012 Share Posted October 15, 2012 Try changing preg_match($suspect to preg_match("/$suspect/" Link to comment https://forums.phpfreaks.com/topic/269495-errors-in-php-code-with-preg_match-functionpreg-match-and-cannot-modify-header-information/#findComment-1385363 Share on other sites More sharing options...
Christian F. Posted October 15, 2012 Share Posted October 15, 2012 Also, please use the [code][/code] tags around your code. It helps make both your post and your code a lot easier to read. Link to comment https://forums.phpfreaks.com/topic/269495-errors-in-php-code-with-preg_match-functionpreg-match-and-cannot-modify-header-information/#findComment-1385371 Share on other sites More sharing options...
andierue Posted October 15, 2012 Author Share Posted October 15, 2012 now comes up with Warning: preg_match() [function.preg-match]: Unknown modifier 'd' in /home/content/52/9922952/html/sg_contact_content/contact_i51contact.php on line 38 Link to comment https://forums.phpfreaks.com/topic/269495-errors-in-php-code-with-preg_match-functionpreg-match-and-cannot-modify-header-information/#findComment-1385374 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.