Hello,
I have a form to add vendor information to a database. At the end of the form are three buttons. Add and Return Home, Add and Add Another, and Cancel.
All three buttons work, except one button does something strange!
The Add and Return Home button works perfectly as well as the Cancel button.
The Add and Add Another works except it adds the current entry 1,311 times. No joke!
Here is the code I am using for the three buttons:
if(isset($_POST['cancel']))
{
echo "<font color=red>ACTION CANCELED BY USER.</font>";
include 'vendor_management_nonav.php';
}
elseif(isset($_POST['addno']))
{
$name = $_POST['name'];
$add1 = $_POST['add1'];
$add2 = $_POST['add2'];
$add3 = $_POST['add3'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$phone = $_POST['phone'];
$fax = $_POST['fax'];
$contact_fname = $_POST['contact_fname'];
$contact_lname = $_POST['contact_lname'];
$contact_email = $_POST['contact_email'];
//Inserts New Vendor Into Table
$vendors = "_vendors";
$company2 = $company;
$company2 = eregi_replace(' ', "_", $company2);
$company_vendors = $company2 . $vendors;
mysql_query("INSERT INTO $company_vendors (name, add1,
add2, add3, city, state, zip, phone, fax, contact_fname,
contact_lname, contact_email) VALUES
('$name', '$add1', '$add2', '$add3', '$city', '$state', '$zip', '$phone',
'$fax', '$contact_fname', '$contact_lname', '$contact_email')")
or die(mysql_error());
include 'vendor_management_nonav.php';
}
elseif(isset($_POST['addmore']))
{
$name = $_POST['name'];
$add1 = $_POST['add1'];
$add2 = $_POST['add2'];
$add3 = $_POST['add3'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$phone = $_POST['phone'];
$fax = $_POST['fax'];
$contact_fname = $_POST['contact_fname'];
$contact_lname = $_POST['contact_lname'];
$contact_email = $_POST['contact_email'];
//Inserts New Vendor Into Table
$vendors = "_vendors";
$company2 = $company;
$company2 = eregi_replace(' ', "_", $company2);
$company_vendors = $company2 . $vendors;
mysql_query("INSERT INTO $company_vendors (name, add1,
add2, add3, city, state, zip, phone, fax, contact_fname,
contact_lname, contact_email) VALUES
('$name', '$add1', '$add2', '$add3', '$city', '$state', '$zip', '$phone',
'$fax', '$contact_fname', '$contact_lname', '$contact_email')")
or die(mysql_error());
include 'vendor_add_nonav.php';
}
else
{
<form here>
The addno button is Add and Return Home the addmore is Add and Add Another. They should both be exactly the same except for the include line because I copied/pasted it. The Add and Add Another is a new feature I'm trying to impliment. Since I copied/pasted I just can't figure out what's wrong.
If anyone has any ideas, I should would appreciate it.
Thanks,
Johnie Karr
Church of Christ
www.godsbible.org