Page 1 of 1

url code for <br>

Posted: Fri Mar 28, 2008 10:24 am
by kryles
Hi,

I am using $_GET to send an error message to the user in the next page, but when the error contains a <br> the URL doesn't have any line break or anything. I tried adding /n instead but again no result. Maybe I am doing it wrong. Here is what I am trying

Code: Select all

 
$query = "  SELECT count(custID)
            FROM Web_Customers
            WHERE custEmail = '".$email."' AND custPassword = '".$password."'";
$result = mysql_query($query);
$count = mysql_result($result,0,0);
 
if($count != 1)
{
     $errMsg .= "   Invalid Email/Password combination<br />
            Did you recently change your password or Email associated with your Account?";
            echo '<META HTTP-EQUIV="refresh" CONTENT="0;URL='.STOREURL.'/login.php?error='.$errMsg.'">';
}
 
next page outputs error, with login form

Code: Select all

 
if(isset($_REQUEST['error']))
    echo strip_tags(trim($_REQUEST['error']));
 
output is

Code: Select all

 
Invalid Email/Password combinationDid you recently change your password or Email associated with your ClearPoint Account?
 
no line break. I looked for a URL code to do line break but couldn't come across anything.
Any help is much appreciated.

Re: url code for <br>

Posted: Fri Mar 28, 2008 10:38 am
by onion2k
urlencode() will help.

Re: url code for <br>

Posted: Fri Mar 28, 2008 10:47 am
by EverLearning
How do you expect to have <br> tags when you process $_REQUEST['error'] with strip_tags(), which as the name suggest, strips html tags.

PHP manual: strip_tags()

If you want to strip all tags except '<br>', strip_tags accepts an optional second parameter to specify tags which should not be stripped.

Code: Select all

 
if(isset($_REQUEST['error']))
    echo strip_tags(trim($_REQUEST['error']), '<br>');
 

Re: url code for <br>

Posted: Fri Mar 28, 2008 10:57 am
by kryles
EverLearning wrote:How do you expect to have <br> tags when you process $_REQUEST['error'] with strip_tags(), which as the name suggest, strips html tags.

PHP manual: strip_tags()

If you want to strip all tags except '<br>', strip_tags accepts an optional second parameter to specify tags which should not be stripped.

Code: Select all

 
if(isset($_REQUEST['error']))
    echo strip_tags(trim($_REQUEST['error']), '<br>');
 
I dont think that has any bearing in this case anyways since in the URL itself (even before I strip tags to put in varuiable) there is no URL encoded characters.

Re: url code for <br>

Posted: Fri Mar 28, 2008 11:00 am
by kryles
After trying it I am proven wrong lol. I thought <br /> would be assigned %7E or something like that, not keep the raw <br />

Anyways, thanks :)