form validation not working
Posted: Mon Jul 08, 2002 8:44 am
I am trying to introduce some form validation into a page. The validation I have attempted to create does not work, in that the forn is still posted.
I have gone though the posts for forms and cannot find any hints to help me. Any ideas?
The form checks to see if it has already been posted using
and it post to itself using action
Please find the following code
I have gone though the posts for forms and cannot find any hints to help me. Any ideas?
The form checks to see if it has already been posted using
Code: Select all
if(!$submit) {and it post to itself using action
Code: Select all
<?php echo $php_self; ?>Please find the following code
Code: Select all
<?php }
else
{
include('pageconnect.php');
$connection = @mysql_connect($host, $user, $pass) or die ("Unable to connect to database");
mysql_select_db($db) or die ("Unable to select database: $db ");
If (($cust_name == "") && ($cust_address == "") && ($postcode == "") && ($dforename == "") && ($dsurname == "")
&& ($dusername == "") && ($dpasword == "") && ($upload == "") && ($cust_email == "") )
{
echo "You have not completed all required fields";
}
else
{
$sql="INSERT INTO customer (cont_type_id, cust_name, cust_address, postcode, cust_phone,
cust_fax, cust_mobile, cust_email, phone_in, router_in, pcaw, cont_expiry, prospect, prosp_follow, upload)
VALUES ('$cont_type_id', '$cust_name', '$cust_address', '$postcode', '$cust_phone',
'$cust_fax', '$cust_mobile', '$cust_email', '$phone_in', '$router_in', '$pcaw', '$cont_expiry', '$prospect', '$prosp_follow', '$upload')
";
mysql_query($sql) or die('An error occured executing sql statement. SQL='.$sql.'<br>'.mysql_error());
$cust_id = mysql_insert_id();
$sql="INSERT INTO dept (cust_id, name, location)
VALUES ('$cust_id', '$dept_name', '$location')
";
mysql_query($sql) or die('An error occured executing sql statement. SQL='.$sql.'<br>'.mysql_error());
$dept_id = mysql_insert_id();
$sql="INSERT INTO users (dept_id, username, password, defaultuser, forename, surname, job_title, user_address,
user_postcode, user_phone, user_fax, user_mobile, user_email)
VALUES ('$dept_id', '$dusername', '$dpassword', 'Yes', '$dforename', '$dsurname', '$job_title', '$cust_address', '$postcode',
'$cust_phone', '$cust_fax', '$cust_mobile', '$cust_email')
";
mysql_query($sql) or die('An error occured executing sql statement. SQL='.$sql.'<br>'.mysql_error());
?>
<script type="text/javascript">
location.href = "custconfirm.php";
</script>
<?php }
mysql_close($connection);
}
?>