#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    I am having a difficult time passing text from one form to the next, or more over, back to the original form.

    On a user registration form I collect a prospective users data and pass it to another form to validate the info. If the fields are completed as required, they are offered the chance to go back and edit their info.

    I send the original info back in hidden form fields and all works well except the textarea or long text box which have quotations in them.

    I have employed the stripslashes() function and while it works like a charm to display the text as it was entered so the user can verify it, this function will not populate a form field properly. Or at least I cannot get it to work!

    Here is my code (simplified):

    <?PHP
    //File Name: form1.php
    //Date: Friday, October 27, 2000 2:07:50 PM

    ?>


    <form action="form2.php" method="post" name="test" id="test">
    <input type="text" name="form1_test" size="40" maxlength="40" value="<?PHP echo stripslashes("$form2_test");?>">

    <input type="submit" name="submit" value="Done">

    </form>

    ----------------------------------

    <?PHP
    //File Name: form2.php
    //Date: Friday, October 27, 2000 2:09:45 PM

    ?>

    <p>Please verify your information.</p>

    Your info: <?PHP Print(stripslashes("$form1_test")); ?>
    <br>
    <form action="form1.php" method="post" name="test" id="test">
    <input type="hidden" name="form2_test" size="40" maxlength="40" value="<?PHP echo "$form1_test"; ?>">

    <input type="submit" name="submit" value="<--Edit">

    </form>

    I have tried many variations of Print() and echo and nothing I do seems to work. Can I populate a text box in this mannor?

    Kevin
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    41
    Rep Power
    14
    The first problem I see is that when you use stripslashes the first time in form2.php, you are only doing it for one instance of the print. You are not reassigning the variable to itself with stripslashes, merely printing it out as so.

    Instead of
    <?PHP ech "$blah";?>
    Just do:
    <?PHP=$blah?>

    And in first PHP tags, use:
    $form2_test = stripslashes($form2_test);
    and
    $form1_test = stripslashes($form1_test);

    And for form fields and quotes in general, they are done in HTML as &quot;, get rid of the two 's

    [This message has been edited by Krucifyx (edited October 27, 2000).]
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    Thank you Krucifyx for your reply,

    I still haven't gotten it.

    The first bit you spoke of,

    "The first problem I see is that when you use stripslashes the first time in form2.php, you are only doing it for one instance of the print. You are not reassigning the variable to itself with stripslashes, merely printing it out as so."

    This I understand. I am merly printing this out on form2 so the user can view the info they posted. The hidden field on form2 is where I am having trouble.

    <input type="text" name="form1_test" size="40" maxlength="40" value="<?PHP echo stripslashes("$form2_test");?>">

    I have tried:
    value="<?PHP $form1_test ?>"
    and
    value="<?PHP stripslashes($form1_test); ?>"


    and both of the above with echo or print().

    What I get returned to form1 is either nothing at all or one or two backslashes().

    Then again this may have to do with how I am asigning the value to the field in form1.

    There again, on form1 (where the data came from to begin with) I have tried all of the above mentioned methods as well as addslashes() just for fun!

    I maybe didn't understand what you meant by just do <?PHP=$form1_test?>

    do you mean what I mentioned above:
    value="<?PHP $form1_test?>"

    I just don't get it! I have written more complicated things than this. I understand the theory but I can't get it to work in practice.


    Any further thought on this? I'll keep plugging away for now!

    Thank You!

    Kevin
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    41
    Rep Power
    14
    Ok, so you can print out the contents of form1_test fine OUTSIDE of the input field, right? And within the input field, verything is cut off after any "'s, right?
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    Right, that's that's what was happening but not anymore! I'm happy to report after further review of the book and another attempt with something I had already tried, it now works!

    Note the addition of htmlspecialchars() to my code.

    Here is what I have now.


    <?PHP
    //File Name: form1.php
    //Date: Friday, October 27, 2000 2:07:50 PM

    ?>

    <!--Display the user input for user to validate, decide if they need to edit.-->
    Your info as it was returned from form2: <?PHP print($form2_test);?><br>

    <p>Enter some text with "Quotes"!</p>
    <form action="form2.php" method="post" name="test" id="test">
    <input type="text" name="form1_test" size="40" maxlength="40" value="<?PHP PRINT(htmlspecialchars(stripslashes("$form2_test")));?>">

    <input type="submit" name="submit" value="Done">

    </form>

    <!--------------------------------------------------------------------------------->


    <?PHP
    //File Name: form2.php
    //Date: Friday, October 27, 2000 2:09:45 PM

    ?>

    <p>Please verify your information.</p>

    <!--Display the user input for user to validate, decide if they need to edit.-->
    Your info: <?PHP print(stripslashes($form1_test));?><br>


    <br>
    <form action="form1.php" method="post" name="test" id="test">
    <input type="text" name="form2_test" size="40" maxlength="40" value="<?PHP PRINT(htmlspecialchars(stripslashes("$form1_test")));?>"><BR>

    <input type="submit" name="submit" value="<--Edit">

    </form>


    Entering "TEST" on form1.php gives the following output on form2.php.

    Please verify your information.

    Your info: "TEST"


    (and the text box shows "TEST"

    Then when you go back (click edit) the out put on form1.php is:

    Your info as it was returned from form2: "TEST"

    Enter some text with "Quotes"!

    (text box)"TEST"

    [This message has been edited by RoadKingHD (edited October 30, 2000).]

    [This message has been edited by RoadKingHD (edited October 30, 2000).]

Similar Threads

  1. help with tables and wordwrapping
    By junkedBrian613 in forum PHP Development
    Replies: 2
    Last Post: February 15th, 2004, 05:42 PM
  2. Updating text fields from dynamic SQL select box?
    By Trent Hatred in forum HTML Programming
    Replies: 3
    Last Post: February 6th, 2004, 10:34 AM
  3. how to keep table on top, not centered??
    By vinyl in forum HTML Programming
    Replies: 2
    Last Post: January 20th, 2004, 06:19 PM
  4. float question
    By yeah-yeah in forum HTML Programming
    Replies: 10
    Last Post: January 15th, 2004, 03:59 PM
  5. Javascript scrollbar - stuck on last bit
    By NayMyoSan in forum JavaScript Development
    Replies: 0
    Last Post: January 3rd, 2004, 12:05 PM

IMN logo majestic logo threadwatch logo seochat tools logo