Hello,
I am a PHP newbie. I have a mySQL database (customers) that logs cutomer info properly when they create an account. I want them to opt in to be an affiliate. If they are a customer and want to become and affiliate I want them to complete an abriviated form.
1) The form gathers a couple of pieces of information and posts it to the database (affiliate)
2) I want the remaining information needed to come from the existing database (customers) and insert into (affiliate)
3) The following snippet works except it will not write the information from (customers) to (affiliate) Any help is greatly appreciate.
Cheers,
Chris
// Open database...
$db = mysql_connect("localhost", "$databaseuser", "$databasepasswd");
mysql_select_db("$databasename",$db);
// Check and store affiliate data...
$sql="SELECT email FROM customers WHERE email='$email'";
$result = mysql_query("$sql",$db);
if (mysql_num_rows($result) == 0) {
header("Location:error4.html");
exit;
}
//start query of customers table for info
$sql="SELECT email,firstname,lastname FROM customers WHERE email='$email'";
$result = mysql_query("$sql",$db);
//end query of customers table for info
$sql = "INSERT INTO affiliate (user, password, firstname, lastname, email,affiliate_id) VALUES ('user', '$password', '$firstname', '$lastname', '$email', 0)";
$result = mysql_query("$sql",$db);
$customers_affiliate_id = mysql_insert_id();
$sql = "INSERT INTO affiliate_stats (clicks, orders, id) VALUES (0, 0, '$affiliate_id')";
$result = mysql_query("$sql",$db);
// Close database...
mysql_close($db);