Jump to content

Double Entry


herghost

Recommended Posts

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');

?>

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.