cdavenport4
04-30-2007, 02:26 AM
I need to be able to validate each field. I can do this on a massive scale but I need to know where someone makes a mistake.
example of a couple of validations I'm doing now... but it puts a single entry on each time I do this.
if ($dealership) {
$query = sprintf("INSERT INTO dealershipinfo (dealership) VALUES ('$dealership')");
mysql_query($query) or die(mysql_error());
echo "<table width=\"100%\" border=\"0\"><tr><td bgcolor=\"#0099FF\"><font color=\"#FFFFFF\">Dealership Information has been added.</font></td></tr></table>";
} elseif ($submitted) {
echo "<table width=\"100%\" border=\"0\"><tr><td bgcolor=\"#CC0000\"><font color=\"#FFFFFF\">Dealership Field is empty!</font></td></tr></table>";
}
if ($address) {
$query = sprintf("INSERT INTO dealershipinfo (address) VALUES ('$address')");
mysql_query($query) or die(mysql_error());
echo "<table width=\"100%\" border=\"0\"><tr><td bgcolor=\"#0099FF\"><font color=\"#FFFFFF\">Address Information has been added.</font></td></tr></table>";
} elseif ($submitted) {
echo "<table width=\"100%\" border=\"0\"><tr><td bgcolor=\"#CC0000\"><font color=\"#FFFFFF\">Address Field is empty!</font></td></tr></table>";
}
Mysql Database
------------------------
1: Dealership
2: ------------ Address
------------------------
Any help would be great.
example of a couple of validations I'm doing now... but it puts a single entry on each time I do this.
if ($dealership) {
$query = sprintf("INSERT INTO dealershipinfo (dealership) VALUES ('$dealership')");
mysql_query($query) or die(mysql_error());
echo "<table width=\"100%\" border=\"0\"><tr><td bgcolor=\"#0099FF\"><font color=\"#FFFFFF\">Dealership Information has been added.</font></td></tr></table>";
} elseif ($submitted) {
echo "<table width=\"100%\" border=\"0\"><tr><td bgcolor=\"#CC0000\"><font color=\"#FFFFFF\">Dealership Field is empty!</font></td></tr></table>";
}
if ($address) {
$query = sprintf("INSERT INTO dealershipinfo (address) VALUES ('$address')");
mysql_query($query) or die(mysql_error());
echo "<table width=\"100%\" border=\"0\"><tr><td bgcolor=\"#0099FF\"><font color=\"#FFFFFF\">Address Information has been added.</font></td></tr></table>";
} elseif ($submitted) {
echo "<table width=\"100%\" border=\"0\"><tr><td bgcolor=\"#CC0000\"><font color=\"#FFFFFF\">Address Field is empty!</font></td></tr></table>";
}
Mysql Database
------------------------
1: Dealership
2: ------------ Address
------------------------
Any help would be great.