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.
HTH
Ignatius
____________________________________________
----- Original Message -----
From: Mignon Hunter
To: [EMAIL PROTECTED]
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.
Thanks
Mignon
Here's the code for form1.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<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");
}
endif;
}
?>
<table align="center" cellpadding="5">
<tr>
<th colspan="2">Please Enter the Information Below and Press the
'Submit' <br>Button When Finished.<br>(All Fields Required)</th>
<tr><td> </td></tr>
</tr>
<tr>
<td><b>
Company Name: </b></td>
<td>
<input type="text" name="comp_name" size="50">
</td>
</tr>
<tr>
<td>
<b>City:</b></td>
<td>
<input type="text" name="city" size="50">
</td>
</tr>
<tr>
<td>
<b>Contact Name: </b></td>
<td>
<input type="text" name="contact" size="50">
</td>
</tr>
</table>
<center>
<input name="submit" value="Submit" type="submit">
</center>
<?
//This works with form action form1.php
//if (isset ($submit)) {
//check_form($comp_name, $city, $state, $contact);
//}
//echo "$comp_name, $city, $state, $contact";
?>
</form>
</table>
</body>
</html>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php