Submitting HTML into PHP forms

Discussion in 'PHP' started by genji, Sep 12, 2009.

  1. #1
    Hey guys I've got somewhat of a problem I can't seem to get out of.

    I currently have a php form with a text-area which I want to put the following html into:

    
    <ul class="post">
    <li><a href="lol.com">hello</a></li>
    <li><a href="lole.com">there</a></li>
    </ul>
    
    
    Code (markup):
    The form accepts the html but when it comes to displaying what I've put into the text area, it does not use the post class that i've used in the text area..
    So the information I'm trying to display will be all messed up.


    Can anyone here help me out please?
     
    genji, Sep 12, 2009 IP
  2. dweebsonduty

    dweebsonduty Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    Digital Goods:
    1
    #2
    Have you tried htmlspecialchars?

    
    <?php
    $string = htmlspecialchars($string);
    ?>
    
    PHP:
     
    dweebsonduty, Sep 12, 2009 IP
  3. genji

    genji Peon

    Messages:
    61
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Nope.. i tried that too man, doesn't work :(
     
    genji, Sep 12, 2009 IP
  4. dweebsonduty

    dweebsonduty Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    Digital Goods:
    1
    #4
    What is the output exactly?
     
    dweebsonduty, Sep 12, 2009 IP
  5. dweebsonduty

    dweebsonduty Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    Digital Goods:
    1
    #5
    I had to use stripslashes.

    http://www.dweebsonduty.com/new/htmlform.php

    <html>
    <head>
    <style type="text/css">
      .post{
      background: #cccccc;
      padding: 10px;
      border: black solid 1px;
      }
    </style>
    </head>
    <body>
    <form action="htmlform.php" method="post">
    <textarea name="textarea"></textarea>
    <input type="submit" value="Submit">
    </form>
    <?php
    echo stripslashes($_POST["textarea"]);
    ?>
    <div class="post">HI</div>
    </body>
    </html>
    
    Code (markup):
     
    dweebsonduty, Sep 12, 2009 IP
  6. genji

    genji Peon

    Messages:
    61
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    oh nvm i found the source of the problem. it appears I had PHP inside the HTML i was trying to put into the PHP form.

    lol
     
    genji, Sep 12, 2009 IP