url code for <br>

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kryles
Forum Contributor
Posts: 114
Joined: Fri Feb 01, 2008 7:52 am

url code for <br>

Post 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.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: url code for <br>

Post by onion2k »

urlencode() will help.
User avatar
EverLearning
Forum Contributor
Posts: 282
Joined: Sat Feb 23, 2008 3:49 am
Location: Niš, Serbia

Re: url code for <br>

Post 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>');
 
kryles
Forum Contributor
Posts: 114
Joined: Fri Feb 01, 2008 7:52 am

Re: url code for <br>

Post 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.
kryles
Forum Contributor
Posts: 114
Joined: Fri Feb 01, 2008 7:52 am

Re: url code for <br>

Post 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 :)
Post Reply