I am having a problem with a script that simply updates a few fields in a
database however, I am having a problem having the script to not update the
database fields if the form is invalid... Here is my script, I don't want
you to fix it for me unless you show me where I am going wrong or can point
me to a good tutorial on this type of function. Thanks in advance,
Jas
<?php
# trim extra spaces from these variables
$c_name = trim($c_name);
$s_addy = trim($s_addy);
$city = trim($city);
$state = trim($state);
$zip = trim($zip);
$phone = trim($phone);
if($c_name == "")
{
$c_nameerr = "Please enter your Company Name<br>";
$formerr = $formerr + 1;
}
if($s_addy == "")
{
$s_addyerr = "Please enter your Street Address<br>";
$formerr = $formerr + 1;
}
if($city == "")
{
$cityerr = "Please enter your City<br>";
$formerr = $formerr + 1;
}
if($state == "")
{
$stateerr = "Please enter your State<br>";
$formerr = $formerr + 1;
}
if($zip == "")
{
$ziperr = "Please enter your Zip Code<br>";
$formerr = $formerr + 1;
}
if($phone == "")
{
$phoneerr = "Please enter your Phone Number<br>";
$formerr = $formerr + 1;
}
# ------------- connects to the mysql database to edit information
$db_name = "test";
$table_name = "www_demo";
$connection = @mysql_connect("localhost", "user", "password") or die ("Could
not connect to database. Please try again later.");
$db = @mysql_select_db("$db_name",$connection) or die ("Could not select
database table. Please try again later.");
$sql = "UPDATE $table_name SET
c_name=\"$c_name\",s_addy=\"$s_addy\",city=\"$city\",state=\"state\",zip=\"z
ip\",phone=\"$phone\"";
$result = @mysql_query($sql, $connection) or die ("Could not execute query.
Please try again later.");
# --------------------------------------------------------------
?>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php