textarea lost on validation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jbol
    New Member
    • Jul 2006
    • 1

    textarea lost on validation

    I am fairly new to this so forgive me if the answer is obvious.
    I have written a PHP form script that validates itself by posting back to itself.
    I use VALUE=$var for all the input fields so I don't lose the inputted values.
    Except the textarea does not seem to support VALUE= and its input is lost if the form input has errors.
    What do I need to do to preserve the value of the textbox?
    thanx in advance
    jim
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    remember textarea has an opening and closing tag, the initialisation data goes inbetween them

    [html]
    <textarea><?p hp echo $TextAreaData; ?></textarea>
    [/html]

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      In order to preserve it you have to give the textarea a name. That name will show up in your $_POST array.

      [PHP]<?php
      // At the beginning of your program you validate the $_POSTs
      if (isset($_POST['that']) {
      // checkit
      }
      // else display the form again
      else {
      <textarea name="that"><?p hp if isset($_POST['that']) echo $_POST['that'] ?></textarea>
      other input, submit, etc.....
      }
      [/PHP]
      Ronald :cool:

      Comment

      Working...