retaining form values

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • desh

    retaining form values

    hello

    How to retain the values in form tag ,in case user enter wrong
    information.

  • frizzle

    #2
    Re: retaining form values


    desh wrote:[color=blue]
    > hello
    >
    > How to retain the values in form tag ,in case user enter wrong
    > information.[/color]

    Not sure if this is what you mean but:

    <form action="process page.php" method="post" name="form" target="_top"
    id="form">
    <input name="email" type="text" id="email" maxlength="80"< ?php echo(
    isset( $_POST['email'] ) ) ? ' value="'.$_POST['email'].'"' : ''; ?>>
    </form>

    (3 lines actually, but google breaks 'em up ...)

    Frizzle.

    Comment

    • David Haynes

      #3
      Re: retaining form values

      desh wrote:[color=blue]
      > hello
      >
      > How to retain the values in form tag ,in case user enter wrong
      > information.
      >[/color]

      One way is to do something like this:

      form1.php displays the form and has <input> fields in it. The form has
      an action - say form1.ctrl.php and will use the POST method.

      form1.ctrl.php processes the $_POST array and saves the values into a
      $_SESSION when an error occurs (along with an error message). It then
      redirects to form1.php.

      form1.php sees the values in the $_SESSION and puts them back into the
      form <input> using the value="" argument.

      You can use GET instead of PUT.
      You can use GET instead of SESSION.

      It really depends on what you need.

      -david-

      Comment

      • desh

        #4
        Re: retaining form values

        thanks for you reply

        Comment

        Working...