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 7 of 7
  1. #1
    New Coder
    Join Date
    May 2006
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form Post - Slashes - Help!

    Hi, I'm very new with php so it might be hard for me to explain what I'm trying to say and do. On the page "site.php", there's a textarea with a html code to google inside it. When someone submits that form, it'll send them to preview.php with the hardlink outside the textarea AND the source code to the hardlink inside the textarea.

    The problem is that preview.php is giving out slashes:


    <a href=\"http://www.google.com\">google</a>

    Code:

    site.php
    <form action="preview.php" method="post">
    <input type="hidden" name="action" value="preview">
    <textarea class="hidden" name="preview">
    <a href="http://www.google.com">google</a>
    </textarea>
    <input type="submit" name="view" value="Preview">
    </form>


    preview.php
    <? echo ''.$_POST['preview'].'';?>
    <br><br>
    <textarea><? echo ''.$_POST['preview'].'';?></textarea>

    I hope someone could help me out.

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    welcome here!

    use
    PHP Code:
    stripslashes($_POST['preview']) 
    to remove them

    manual: http://uk.php.net/manual/en/function.stripslashes.php
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #3
    New Coder
    Join Date
    May 2006
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by raf
    welcome here!

    use
    PHP Code:
    stripslashes($_POST['preview']) 
    to remove them

    manual: http://uk.php.net/manual/en/function.stripslashes.php

    So do I do this?:

    <? echo stripslashes($_POST['preview']);?>
    <br><br>
    <textarea><? echo stripslashes($_POST['preview']);?></textarea>

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    or you coud use
    PHP Code:
    <?php
    $post_preview_url 
    stripslashes($_POST['preview']);
    echo 
    $post_preview_url'<br /><br /><textarea>'$post_preview_url ,'</textarea>';
    ?>
    --> set the variables at the top of your script is more transaprant and easier to maintain + you only need to process them once
    --> don't use shorttags (<? and ?>) since they wount work on all servers. use <?php and ?>
    --> don't drop in and out of php mode, just echo out the html in single quoted strings
    --> use echo with multiple arguments, concatinated with ',' because this uses less runtime resources then an echo 'string1' . 'string2' etc
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #5
    New Coder
    Join Date
    May 2006
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wow that's a lot more convienant. Thanks a lot Raf for your help.

  • #6
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you are wanting a more advanced text area then look into using a Rich Text Editor such as KTML Lite or FCKEditor

  • #7
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by curb
    Wow that's a lot more convienant. Thanks a lot Raf for your help.
    you're welcome
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html


  •  

    Posting Permissions

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