Hi all,
Please look at this code and see if you can help.
Everything works fine except I have two possible values to insert to table2 in the usergroup field, (member / non member) and this should depend on what value is inserted into table1, 'category' field.
I don't know whther this is should be done in SQL or PHP?
Any suggestions please.
$db_name = "xxxxxxx";
$table_name1 = "table1";
$table_name2 = "table2";
$connection = @mysql_connect("localhost", "xxxxxxx", "xxxxxx") or die("couldn't connect.");
$db
= @mysql_select_db($db_name, $connection) or die("couldn't select database.");
$sql = "INSERT into $table_name1
( customer_id, category, tradesector_id, tradebusiness_types, tradepost_en, entry_type, entered_by, date, source_language)
VALUES
( '$id' , '$_POST[category]', '$_POST[tradesector]', '$_POST[tradebusinesstypes]', '$_POST[tradeposten]', '$_POST[entrytype]', '$_POST[enteredby]', CURDATE(), 'en' )";
$result = @mysql_query($sql, $connection) or die ("could not execute query1.");
$cid = mysql_insert_id();
$sql = "INSERT into $table_name2
( customer_id, email, password, usergroup)
VALUES
( '$cid', '$_POST[email]', '$_POST[password]', 'member')";
$result = @mysql_query($sql, $connection) or die ("could not execute query2.");