www.webdeveloper.com
Results 1 to 2 of 2

Thread: form/preview/submit double quotes problem

Hybrid View

  1. #1
    Join Date
    Mar 2014
    Posts
    1

    form/preview/submit double quotes problem

    Hello everyone, I have problem with double quotes when passing input value from form -> preview -> submit. My code is as following:

    form.php
    Code:
    <form action="preview.php" method="post">
            <textarea name="contents" rows="4" cols="60" >contents</textarea>
    <input type="submit" name="button3" value="submit" />
    preview.php
    Code:
    <?php
        //Gather the information entered from form for preview
        $contents = $_POST['contents'];
    ?>
    
    <form action="submit.php" method="post">
    	<input type="hidden" name="contents" value="<?php print "$contents"; ?>" />
            <input type="submit" name="button3" value="submit" />
    </form>
    
    <p><?php print"$contents"; ?></p>
    submit.php
    Code:
    <?php
            $contents = $_POST['contents'];
    ?>
    
    <p><?php print"$contents"; ?></p>
    My current problem is when the input textarea value contains double quotes. In the preview.php stage, it looks fine, but in the submit stage, the text is truncated at the first double quotes encountered. In submit.php, I also enter the $contents value into an MySQL database TEXT field as well. The text is also truncated in the database.

    Please help. Thanks.

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,327
    PHP Code:
    <input type="hidden" name="contents" value="<?php print htmlspecialchars($contents); ?>" />
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles