Narutio Posted October 9, 2008 Share Posted October 9, 2008 Hey guys. Im a noob here, and also on PHP. anyways my problem is im trying to enter the captcha value wrong so i can see what message i get (and also to see if everything works). i got the codes from this site and i havent change any coding only the email. This is the error msg im getting "Warning: Header may not contain more than a single header, new line detected. in /home/egyptian/public_html/mailer.php on line 24" i have wrote in the code where line 24 is. using. before the doctype. The code im using is : <?php // load the variables form address bar $subject = $_REQUEST["subject"]; $message = $_REQUEST["message"]; $from = $_REQUEST["from"]; $verif_box = $_REQUEST["verif_box"]; // remove the backslashes that normally appears when entering " or ' $message = stripslashes($message); $subject = stripslashes($subject); $from = stripslashes($from); // check to see if verificaton code was correct if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){ // if verification code was correct send the message and show this page mail("[email protected]", 'Online Form: '.$subject, $_SERVER['REMOTE_ADDR']."\n\n".$message, "From: $from"); // delete the cookie so it cannot sent again by refreshing this page setcookie('tntcon',''); } else { // if verification code was incorrect then return to contact page and show error <This is line 24> header("Location:".$_SERVER['HTTP_REFERER']."?subject=$subject&from=$from&message=$message&wrong_code=true"); exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>E-Mail Sent</title> <style type="text/css"> <!-- body,td,th { font-family: Arial, Helvetica, sans-serif; font-size: 12px; } --> </style></head> <body>l Email sent. Thank you.<br /> <br /> Return to <a href="/">home page</a> ? </body> </html> Im sorry i dont know how to paste code with line number.. I hope someone can help me with this error and also enlighten me how to copy with line numbers. haha Thanks in advance guys & girls Link to comment https://forums.phpfreaks.com/topic/127710-error-on-line-24-php-contact-form-with-captcha/ Share on other sites More sharing options...
Narutio Posted October 9, 2008 Author Share Posted October 9, 2008 I have read the header page solution but im new to php so i dont understand all this. i just copied this from a site, without changing it and it works there. just not with me. Im sorry, for being a noob and not understanding. Thanks Link to comment https://forums.phpfreaks.com/topic/127710-error-on-line-24-php-contact-form-with-captcha/#findComment-660911 Share on other sites More sharing options...
Narutio Posted October 10, 2008 Author Share Posted October 10, 2008 Please guys. i realy need help. is there no1 kind enuf to help me as far as i know there is no space but still getting this error.. really desperate for this solution. Thanks .. Link to comment https://forums.phpfreaks.com/topic/127710-error-on-line-24-php-contact-form-with-captcha/#findComment-661790 Share on other sites More sharing options...
GingerRobot Posted October 10, 2008 Share Posted October 10, 2008 The problem is actually given in the error message - one of the variables in your query string (i would guess $message) contains a new line and this cannot be present in the header redirect. You can get around this by using the url_encode() function on the variables before you put them in the query string and then use the url_decode() function when you want to use the variables. However, i better solution would be to not perform a redirect at all. You're redirecting to the current page so I assume you're form is on the same page as the processing? In which case, you should just be able to alter your logic so that the form is redisplayed with the information filled in if there is an error. Link to comment https://forums.phpfreaks.com/topic/127710-error-on-line-24-php-contact-form-with-captcha/#findComment-661802 Share on other sites More sharing options...
Narutio Posted October 10, 2008 Author Share Posted October 10, 2008 Thanks for your reply, but i am a noob in php. so i dont understand this & i know i sudnt be using php if i dont know how to use it, all i did was copy the code from another site where it works but i cant get it to work. i just wanted to use a script for the contact info page. is this what you mean? header("Location:".$_SERVER['HTTP_REFERER'];urlencode("?subject=$subject&from=$from&message=$message&wrong_code=true"); exit; Link to comment https://forums.phpfreaks.com/topic/127710-error-on-line-24-php-contact-form-with-captcha/#findComment-661809 Share on other sites More sharing options...
GingerRobot Posted October 10, 2008 Share Posted October 10, 2008 Not quite. I mean like this: header("Location:".$_SERVER['HTTP_REFERER'].urlencode("?subject=$subject&from=$from&message=$message&wrong_code=true")); However, you'll also need to use the urldecode function on the variables on the page that you are redirecting to. Link to comment https://forums.phpfreaks.com/topic/127710-error-on-line-24-php-contact-form-with-captcha/#findComment-661899 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.