RE: [PHP] form submission error trappingThanks for the code.... Is there a
way to keep track of what fields had the errors as its possible for people
to have like 5 errors?

Thanks again.

Jason
  -----Original Message-----
  From: Martin Towell [mailto:[EMAIL PROTECTED]]
  Sent: February 17, 2002 6:41 PM
  To: '[EMAIL PROTECTED]'; Steven Walker
  Cc: [EMAIL PROTECTED]
  Subject: RE: [PHP] form submission error trapping


  something like:

  <?
    // filename: here.html

    if ($submit)
    {
      $error = false;
      if (trim($email) == "")
      {
        $error = true;
      }
      // process more...
      if (!$error)
      {
        // do stuff here, maybe a header("location:....");
        exit;
      }
    }
  ?>
  <html>
    <form action="here.html" method="post">
      <input type="text" name="email" value="<?= $email; ?>">
      <input type="submit" name="submit" value="Go For It!!!">
    </form>
  </html>

  not tested but should work - just expand on it

  Martin



  -----Original Message-----
  From: Jason Dulberg [mailto:[EMAIL PROTECTED]]
  Sent: Monday, February 18, 2002 10:22 AM
  To: Steven Walker
  Cc: [EMAIL PROTECTED]
  Subject: RE: [PHP] form submission error trapping



  Ya, it would be cool if you could.... how do you submit the form to
itself?

  Right now, I have something like

  if (!$submit) {
  display form
  }
  else {
  process
          if (trim($email)=="") {
                  echo "error, hit back button to fix";
          }
  }

  Thanks

  Jason



  > -----Original Message-----
  > From: Steven Walker [mailto:[EMAIL PROTECTED]]
  > Sent: February 17, 2002 6:18 PM
  > To: [EMAIL PROTECTED]
  > Cc: [EMAIL PROTECTED]
  > Subject: Re: [PHP] form submission error trapping
  >
  >
  > Jason,
  >
  > I just finished one of my form pages, and I'm really happy with how it
  > turned out.
  >
  > I created one php page that both displays the form and validates the
  > input. When the user hits the submit button, it submits the data to
  > itself. If anything is missing from the page, the form is reshown with
  > missing fields highlighted and the other fields filled in. If on the
  > other hand the info passes the validation test, the information is shown
  > to screen a new button (hidden form) allows the user to continue.
  >
  > If you want, I can send you a link to my test site so you can check it
  > out.
  >
  > Steven J. Walker
  > Walker Effects
  > www.walkereffects.com
  > [EMAIL PROTECTED]
  >
  > On Sunday, February 17, 2002, at 02:22  PM, Jason Dulberg wrote:
  >
  > > I am working on some error trapping for several forms on my site.
After
  > > visiting a bunch of websites, I've noticed 2 common methods of
  > > displaying
  > > error messages.
  > >
  > > 1. display an error box on a new page and force the user to hit the
  > > <back>
  > > button
  > >
  > > 2. display the form again with appropriate error text and pre-filled
  > > fields.
  > >
  > > I have part of the error on the new page working but I'm running into
  > > the
  > > infamous no contents in the form after going <back>.
  > >
  > > There are some useability issues with forcing the user to hit the back
  > > button -- some just don't want to bother.
  > >
  > > Is there a way to display the form w/original contents and error
  > > messages
  > > 'without' having to code the entire form twice? I have about 5 forms
  > > with 50
  > > fields or so each.
  > >
  > > What would be the best way to go about redrawing the form with the
  > > errors
  > > shown beside each field?
  > >
  > > Any suggestions are greatly appreciated.
  > >
  > > __________________
  > > Jason Dulberg
  > > Extreme MTB
  > > http://extreme.nas.net
  > >
  > >
  > > --
  > > PHP General Mailing List (http://www.php.net/)
  > > To unsubscribe, visit: http://www.php.net/unsub.php
  > >
  > >
  >

  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to