Page 1 of 1

textarea request url problem (new header line detected)

Posted: Fri Nov 28, 2008 2:28 am
by disconne
Hi everyone,

for my comment script I have a problem: if user comment is validated, there is no problem. Everything is Ok. But, if visitor uses 'ENTER' for new paragraphs in his/her comment and form is not validated (for example wrong captcha input), mysql gives error and says Warning: Header may not contain more than a single header, new line detected. in /home/disconne/public_html/0/yazipaylas/yazipaylaskonf.php on line 29 (normally, it should return previous form page with validated fields are full of visitor entered before and only shoul say way the form is not validated and what should visitor do)



My problematic line is header("Location:".$_SERVER['HTTP_REFERER']."?isimx=$isimx&yazibasligi=$subje&epostadres=$kimden&kaynak=$source&lakap=$nick&yazicerik=$messagex
&wrong_code=true");


I learned from web that i think I should use urlencode(), htmlspecialchars() or something similar .. i have no experience about these functions and all my trials are unsuccessful

My raw code of my related page is below

All kind detailed helps are appreciated

best regards

Code: Select all

 
<?php 
// load the variables form address bar
$subje = $_REQUEST["yazibasligi"];
$messagex = $_REQUEST["yazicerik"];
$kimden = $_REQUEST["epostadres"];
$verif_box = $_REQUEST["verif_box"];
$isimx = $_REQUEST["isimx"];
$source = $_REQUEST["kaynak"];
$nick = $_REQUEST["lakap"];
 
// remove the backslashes that normally appears when entering " or '
$messagex = stripslashes($messagex); 
$subje = stripslashes($subje); 
$kimden = stripslashes($kimden); 
$isimx = stripslashes($isimx);
$source = stripslashes($source);
$nick = stripslashes($nick);
 
include("{$kokdizin}functions/emailaddresscheck.php");
 
// check to see if verificaton code was correct
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon'] && $nick !='' && $messagex!='' && $subje!='' && $kimden!='' && $isimx!='' && check_email_address($kimden) ){
    // if verification code was correct send the message and show this page
    mail("someone@someservice.com", 'BLA_BLA_YAZI_PAYLASIMI: '.$subje, 'Gonderen ip no : '.$_SERVER['REMOTE_ADDR']."\n\n".'Gonderen Isim : 
 
'.$isimx."\n\n".'Varsa Alinti Kaynak Bilgisi : '.$source."\n\n".' Varsa Gonderenin Kullanilmasini Istedigi Lakap : '.$nick."\n\n".'Paylasilan Yazi (Asagida) : 
 
'."\n\n".$messagex, "From: $kimden");
    // 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      
    
 
header("Location:".$_SERVER['HTTP_REFERER']."?isimx=$isimx&yazibasligi=$subje&epostadres=$kimden&kaynak=$source&lakap=$nick&yazicerik=$messagex&wrong
 
_code=true");
    exit;
}?>
 

Re: textarea request url problem (new header line detected)

Posted: Fri Nov 28, 2008 2:53 am
by pcoder
I think , this is because of the spaces in the header location.
So remove the spaces and try it.

Code: Select all

header("Location:".$_SERVER['HTTP_REFERER']."?isimx=$isimx&yazibasligi=$subje&epostadres=$kimden&kaynak=$source&lakap=$nick&yazicerik=$messagex&wrong_code=true");
8)

Re: textarea request url problem (new header line detected)

Posted: Fri Nov 28, 2008 3:05 am
by disconne
Thank you Pcoder,
I removed some spaces, now in notepad my related code line is
{header("Location:".$_SERVER['HTTP_REFERER']."?isimx=$isimx&yazibasligi=$subje&epostadres=$kimden&kaynak=$source&lakap=$nick&yazicerik=$messagex&wrong_code=true");exit;}?>

but i think problem is different because if visitor submits a verified form in the first trial, i have no problem for sql adding or displaying the comment
any other help !?

Best regards
pcoder wrote:I think , this is because of the spaces in the header location.
So remove the spaces and try it.

Code: Select all

header("Location:".$_SERVER['HTTP_REFERER']."?isimx=$isimx&yazibasligi=$subje&epostadres=$kimden&kaynak=$source&lakap=$nick&yazicerik=$messagex&wrong_code=true");
8)