form validation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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>&nbsp;</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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux