herghost Posted March 6, 2010 Share Posted March 6, 2010 Hi all, for some reason my form action script is entering everything into the database twice? Whats causing this? <?php session_start(); //Customer Details include('../config/connect.php'); $title = (isset($_POST['title'])) ? trim($_POST['title']) : ''; $forename = (isset($_POST['forename'])) ? trim($_POST['forename']) : ''; $surname = (isset($_POST['surname'])) ? trim($_POST['surname']) : ''; $company = (isset($_POST['company'])) ? trim($_POST['company']) : ''; $nameno = (isset($_POST['nameno'])) ? trim($_POST['nameno']) : ''; $fline = (isset($_POST['fline'])) ? trim($_POST['fline']) : ''; $sline = (isset($_POST['sline'])) ? trim($_POST['sline']) : ''; $city = (isset($_POST['city'])) ? trim($_POST['city']) : ''; $state = (isset($_POST['state'])) ? trim($_POST['state']) : ''; $zip = (isset($_POST['zip'])) ? trim($_POST['zip']) : ''; $country = (isset($_POST['country'])) ? trim($_POST['country']) : ''; $tax = (isset($_POST['tax'])) ? trim($_POST['tax']) : ''; //Contact Details $email = (isset($_POST['email'])) ? trim($_POST['email']) : ''; $phone = (isset($_POST['phone']))? trim($_POST['phone']) : ''; $fax = (isset($_POST['fax'])) ? trim($_POST['fax']) : ''; //Account Details $username = (isset($_POST['username'])) ? trim($_POST['username']) : ''; $password = (isset($_POST['password'])) ? md5($_POST['password']): ''; $newsleter = (isset($_POST['newsletter'])) ? trim($_POST['newsletter']) : ''; $query = "INSERT INTO customers (title, forename, surname, company, nameno, fline, sline, city, state, zip, country, tax, email, phone, fax, username, password, newsletter) VALUES ('$title', '$forename', '$surname', '$company', '$nameno', '$fline', '$sline', '$city', '$state', '$zip', '$country', '$tax', '$email', '$phone', '$fax', '$username', '$password', '$newsletter') "; $result = mysql_query($query); if (!mysql_query($query)) { die('Error: ' . mysql_error()); } $_SESSION['addedcustomer'] = 'addedcustomer'; header ('Location: ../home.php'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/194341-double-entry/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 6, 2010 Share Posted March 6, 2010 You have two mysql_query() statements in your code, so of course you will get double entries - $result = mysql_query($query); if (!mysql_query($query)) Computers only do exactly what their code tells them to do. Why does your code execute the query once, then a second time? Quote Link to comment https://forums.phpfreaks.com/topic/194341-double-entry/#findComment-1022341 Share on other sites More sharing options...
herghost Posted March 6, 2010 Author Share Posted March 6, 2010 ah crap, perhaps I was making sure the script was doing what it was told, a bit like a small child, I told it twice to reiterate the point Cheers Quote Link to comment https://forums.phpfreaks.com/topic/194341-double-entry/#findComment-1022342 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.