Passing values using POST

Discussion in 'PHP' started by zerandib, Mar 22, 2009.

  1. #1
    hi

    This is the code related to the form

    <form id="form1" name="form1" method="post" action="saveit.php">
      <label>
      <textarea name="txt1" cols="100" rows="25"></textarea>
      <input type="submit" name="Submit" value="Submit" />
      </label>
    </form>
    PHP:

    when i enter the value "Jane" (with double quote) , and submit i want to display that text
    Here the saveit.php
    echo $_POST["txt1"]);
    PHP:
    But here it displays as
    \"Jane\" (Not as "Jane")

    So how to get the out put as "Jane" (with double quote)


    further , if i enter like
    <html>
    hi
    </html>


    it needs to display as it is.
    currently it shows only: hi
    It removes html tags...

    i want to stop interpreting html. needs to show html as it is.
    how can i do this!
     
    zerandib, Mar 22, 2009 IP
  2. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Case 1, regarding the Jane:
    echo stripslashes($_POST["txt1"]);
    PHP:
    Case 1, regarding the <html>:
    echo htmlentities($_POST["txt1"]);
    PHP:
    So you might want to use this for the overall:
    echo htmlentities(stripslashes($_POST["txt1"]));
    PHP:

    - ads2help
     
    ads2help, Mar 22, 2009 IP
  3. zerandib

    zerandib Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi

    is there a way to stop all these at once....

    interpreting html tags... and things such as

    &amp;
    gt;
    lt;
    &quote;

    etc....

    way to stoping interprting html related things
     
    zerandib, Mar 22, 2009 IP
  4. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #4
    I don't get you. Did you try my last script?

    And you're great, you never even showed your appreciation to other's help in both your posts. Great one dude.

    - ads2help
     
    ads2help, Mar 22, 2009 IP
  5. igor398

    igor398 Guest

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I think
    echo htmlentities(stripslashes($_POST["txt1"]));
    must be the best
     
    igor398, Mar 22, 2009 IP