Tabel bliver ikke opdateret?
Nogen som kan finde ud af hvorfor kunder og ordermain_custnum i ordermain ikke bliver oprettet?<?php
session_start();
?>
<?php
header("refresh: 30;url=index.php");
?><?php
//connect to the database - either include a connection variable file
//or type the following lines:
$connect = mysql_connect("localhost", "designunltdd", "nezam1975")
or die ("Hey loser, check your server connection.");
mysql_select_db("designunltddk_shop");
//Let's make the variables easy to access in our queries
$fornavn = $_POST['fornavn'];
$efternavn = $_POST['efternavn'];
$adresse1 = $_POST['adresse1'];
$adresse2 = $_POST['adresse2'];
$by = $_POST['by'];
$postnr = $_POST['postnr'];
$telefon = $_POST['telefon'];
$mobil = $_POST['mobil'];
$email = $_POST['email'];
$password = $_POST['password'];
$shipfornavn = $_POST['shipfornavn'];
$shipefternavn = $_POST['shipefternavn'];
$shipadresse1 = $_POST['shipadresse1'];
$shipadresse2 = $_POST['shipadresse2'];
$shipby = $_POST['shipby'];
$shippostnr = $_POST['shippostnr'];
$shiptelefon = $_POST['shiptelefon'];
$shipmobil = $_POST['shipmobil'];
$shipemail = $_POST['shipemail'];
$total = $_POST['total'];
$sessid = session_id();
$today = date("d-m-Y");
//1) Assign Customer Number to new Customer, or find existing customer number
$query = "SELECT * FROM kunder WHERE
(kunde_fornavn = '$fornavn' AND
kunde_efternavn = '$efternavn' AND
kunde_adresse1 = '$adresse1' AND
kunde_adresse2 = '$adresse2' AND
kunde_by = '$by')";
$results = mysql_query($query)
or (mysql_error());
$rows = mysql_num_rows($results);
if ($rows < 1) {
//assign new custnum
$query2 = "INSERT INTO kunder (
kunde_fornavn, kunde_efternavn, kunde_adresse1,
kunde_adresse2, kunde_by,
kunde_postnr, kunde_telefon, kunde_mobil,
kunde_email, kunde_pass)
VALUES (
'$fornavn',
'$efternavn',
'$adresse1',
'$adresse2',
'$by',
'$postnr',
'$telefon',
'$mobil',
'$email',
'$password)";
$insert = mysql_query($query2)
or (mysql_error());
$custid = mysql_insert_id();
}
//If custid exists, we want to make it equal to custnum
//Otherwise we will use the existing custnum
if ($custid) {
$kunde_custnum = $custid;
}
//2) Insert Info into ordermain
//determine shipping costs based on order total (25% of total)
$fragt = 48;
$query3 = "INSERT INTO ordermain (
ordermain_orderdato, ordermain_custnum,
ordermain_subtotal, ordermain_fragt,
ordermain_fragtfornavn, ordermain_fragtefternavn,
ordermain_fragtadresse1, ordermain_fragtadresse2,
ordermain_fragtby,
ordermain_fragtpostnr, ordermain_fragttelefon,
ordermain_fragtemail)
VALUES (
'$today',
'$kunde_custnum',
'$total',
'$fragt',
'$shipfornavn',
'$shipefternavn',
'$shipadresse1',
'$shipadresse2',
'$shipby',
'$shippostnr',
'$shiptelefon',
'$shipemail')";
$insert2 = mysql_query($query3)
or (mysql_error());
$orderid = mysql_insert_id();
echo "" . $ordermain_fragtfornavn . "";
//3) Insert Info into orderdet
//find the correct cart information being temporarily stored
$query = "SELECT * FROM carttemp WHERE carttemp_sess='$sessid'";
$results = mysql_query($query)
or (mysql_error());
//put the data into the database one row at a time
while ($row = mysql_fetch_array($results)) {
extract($row);
$query4 = "INSERT INTO orderdet (
orderdet_ordernum, orderdet_qty, orderdet_prodnum)
VALUES (
'$orderid',
'$carttemp_quan',
'$carttemp_prodnum')";
$insert4 = mysql_query($query4)
or (mysql_error());
}
//4)delete from temporary table
$query = "DELETE FROM carttemp WHERE carttemp_sess='$sessid'";
$delete = mysql_query($query);
