Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2006
    Location
    Graz, Austria
    Posts
    81
    Thanks
    2
    Thanked 1 Time in 1 Post

    problems masking html code

    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.

    Code:
    $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
    Last edited by yeti; 06-21-2006 at 02:30 PM.
    webmaster and member of
    http://cashfromchaos.net

  • #2
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    New Coder
    Join Date
    Jun 2006
    Location
    Graz, Austria
    Posts
    81
    Thanks
    2
    Thanked 1 Time in 1 Post
    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:
    PHP 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:
    PHP 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:

    Code:
    <span class=\"warning\">Sorry, You have already posted a Message on this guestbook.<br>Please wait 2 minutes and try again.</span>
    webmaster and member of
    http://cashfromchaos.net

  • #4
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    it would be more logical to do it like this:
    PHP Code:
    // 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 

  • #5
    New Coder
    Join Date
    Jun 2006
    Location
    Graz, Austria
    Posts
    81
    Thanks
    2
    Thanked 1 Time in 1 Post
    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!
    webmaster and member of
    http://cashfromchaos.net


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •