The title is probably complicated, but i'll explain here. SO basically when the customer registers, they get a unique customer code, which is auto incremented in the database. However, while registering, the customer adds credit card info and the customer code is a foreign key in the card table. Now what I want to do is put the customer code into card table. Is it possible or is it better to just ask user to add credit card when registered?
My queries look like this:
<?php
$connection =
mysql_connect("com-db-02.student-cit.local", "team16", "DbSLzU")
or die (mysql_error());
$db = mysql_select_db("team16") or die(mysql_error());
$DepotId = $_POST['depotId'];
$FName = $_POST['custFName'];
$LName = $_POST['custLName'];
$Email = $_POST['custEmail'];
$Address = $_POST['address'];
$Town = $_POST['town'];
$County = $_POST['county'];
$Eircode = $_POST['eircode'];
$Phone = $_POST['phone'];
$Password = $_POST['custPassword'];
$cardtype = $_POST['cardType'];
$cardHolder = $_POST['cardHolder'];
$cardNumber = $_POST['cardnumber'];
$expiryDate = $_POST['expirydate'];
$securitycode = $_POST['securitycode'];
// TO DO OTHER TEXTBOXES
$query1 = "SELECT DEPOTID FROM DEPOT WHERE LOCATION ='$DepotId'";
$result1 = mysql_query($query1);
$depotID = -1;
while($row = mysql_fetch_array($result1))
{
$depotID = $row['DEPOTID'];
}
$query3 = "INSERT INTO card(customerCode) SELECT customerCode * FROM customer WHERE customerCode= customerCode";
$query = "INSERT INTO CUSTOMER(DEPOTID, CUSTFNAME, CUSTLNAME, CUSTEMAIL, ADDRESS, TOWN, COUNTY, EIRCODE,
PHONE, CUSTPASSWORD) VALUES('$depotID','$FName', '$LName', '$Email', '$Address',
'$Town', '$County', '$Eircode', '$Phone', '$Password')";
$query2 = "INSERT INTO CARD(CARDTYPE, CARDHOLDER, CARDNUMBER, EXPIRYDATE, SECURITYCODE, CUSTOMERCODE) VALUES('$cardNumber','$cardtype', '$cardHolder', '$expiryDate', '$securitycode')";
/*$result = mysql_query($query);*/
$result = mysql_query($query2);
$result = mysql_query($query3);
echo $query2();
echo $query3();
?>
I need to put customer code into card table but the code doen't exist yet