Hi Mignon,

it is really quite simple:

you can pack several screens (each containing for instance a form) in a same script.

each form contains a hidden field, say "selector"

now, the script begins by a switch:

if ( isset( $_POST['submit'] ) ) {

switch ( $selector ) { 

// Switch 1: process the screen 1
// -------------------------------------------------
case "1" :

 // process form 1 : data validation, ...
<form name="form2" action="samepage.php>
<input type="hidden" selector="2" />
// ...

break ;

// Switch 2: process the screen 2
// -------------------------------------------------
case "2" :

// etc.
} else {

// show the blank form

Javascript validation is not even a last resort. Use it only for usability purposes, 
but validate everything server-side.

  ----- Original Message ----- 
  From: Mignon Hunter 
  Sent: Friday, December 20, 2002 3:25 PM
  Subject: [PHP-DB] form validation

  Hello list,

  I am developing a db form that gets passed to another form.  I need to
  validate the fields in form(1), before passing on.  The form action
  posts to form(2), so that upon hitting submit - form(2) shows up in
  browser...(the only way I know how to do this). 

  I am trying to use php to validate.  I have been googling and checking
  books and archives for 2 days and all examples use the same file to post
  to.  In other words, form1.php uses form action="form1.php".  But I need
  it to be form(2), but I still need to validate.

  Does anyone have any ideas, or does everyone just use javascript with
  say...alert boxes.  This will be my last resort.  


  Here's the code for form1.php

  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  <form action="form2.php" method="post">

  function check_form($comp_name, $city, $state, $contact) {
          if (!$comp_name || !$city || !$state || !$contact):
          print ("Please fill in all Fields");
          if (!$comp_name) {
          print ("Please fill in your company name");
          if (!$city) {
          print ("Please fill in your city");
          if (!$contact) {
          print ("Please fill in your contact name");

  <table align="center" cellpadding="5">
  <th colspan="2">Please Enter the Information Below and Press the
  'Submit' <br>Button When Finished.<br>(All Fields Required)</th>

  Company Name:  </b></td>
  <input type="text" name="comp_name" size="50">

  <input type="text" name="city" size="50">

  <b>Contact Name:  </b></td>
  <input type="text" name="contact" size="50">
  <input name="submit" value="Submit" type="submit">

  //This works with form action form1.php
  //if (isset ($submit)) {
  //check_form($comp_name, $city, $state, $contact);
  //echo "$comp_name, $city, $state, $contact";



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

Reply via email to