...

View Full Version : problems masking html code



yeti
06-21-2006, 12:58 PM
hi there!

I am modifying a guestbook code and there is one specific line, where I can't escape the double quotes that I want to be parsed to html.


$cookie = setcookie('entry','
<br><br><span class=warning>
Sorry, You have already posted a Message on this guestbook.<br>
Please wait 2 minutes and try again.</span>',time() + (120));
double quotes should be parsed around the term "warning" in the span class.

I know it's not that necessary to have quotes in the html text, but I want to get this right.

In other pieces of code I could easily escape the double quotes by using \" .

any idea what I can do?

thanks in advance

fci
06-21-2006, 02:43 PM
why are you putting html in a cookie? ideally you would set it to be 'warning' or 'no_error' then have it display what you want where ever.

yeti
06-21-2006, 03:31 PM
in my guestbook is an option called for flood protecting the gb

a cookie is set and when the user has posted a short time before (actually 2 min.) the error message is echoed.

in the original code were a lot of html4.02 invalid elements (i.e. <center>), that I could replace - all but in this specific line. I removed the <center> and <font> tags and want to add <span class="warning">...</span> in order to format this warning like the other ones.

original code:

// Checking to see if the visitor has already posted --------------------

if ($gbflood == 1)
{
if (isset($_COOKIE['entry']))
{
include("header.php");
$cookieval = $_COOKIE['entry'];
echo $cookieval;
echo "<center><br><a href=\"javascript:history.go(-1)\" class=\"text\">$goback</a></center>";
include("footer.php");
exit;
}

// Set cookie for flood protection --------------------------------------------------------------
$cookie = setcookie('entry','<br><br><center><font color=red><b>Sorry, You have already posted a Message on this guestbook.<br>Please wait 2 minutes and try again.</b></font><br><br></center>',time() + (120));
} // End of If statement for flooding

modified code:

// Set cookie for flood protection --------------------------------------------------------------
$cookie = setcookie('entry','<span class=\"warning\">Sorry, You have already posted a Message on this guestbook.<br>Please wait 2 minutes and try again.</span>',time() + (120));
} // End of If statement for flooding

I already tried to escape the quotes (that are required in the parsed html), but it did not work. warning was not formatted correctly because of invalid html:


<span class=\"warning\">Sorry, You have already posted a Message on this guestbook.<br>Please wait 2 minutes and try again.</span>

fci
06-21-2006, 03:37 PM
it would be more logical to do it like this:

// Checking to see if the visitor has already posted --------------------

if ($gbflood == 1)
{
if (isset($_COOKIE['entry']))
{
include("header.php");
echo '<span class="warning">Sorry, You have already posted a Message on this guestbook.<br>Please wait 2 minutes and try again.</span>';
echo "<center><br><a href=\"javascript:history.go(-1)\" class=\"text\">$goback</a></center>";
include("footer.php");
exit;
}

// Set cookie for flood protection --------------------------------------------------------------
$cookie = setcookie('entry','1',time() + (120));
} // End of If statement for flooding

yeti
06-21-2006, 03:47 PM
sorry, I'm not that fit in php.

the code works as it is and I don't want to mess it up all for two little quotes...

sorry for bothering you!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum