entering data into two tables when a user registers
Posted: Fri Jul 23, 2010 2:44 pm
Hi, I need to know how I can insert data into two tables when a user registers.
Problem
When a user registers, data is inputted into the users table, thats there name, username password etc, but now i want to make another separate table, which will feature even more registration options, such as their favorite games, website, other emails etc.
The thing is how would i make a blank field in this table while the user registers, so when it comes updating that setting, its just a simple update query.
Here is the insert code:
and here is the code i thought would work:
So if anyone would help, it would be very hellpful indeed lol.
James
fyi, you may need explain ur answer, as im not always able to understand, still a newbie at this xD
Problem
When a user registers, data is inputted into the users table, thats there name, username password etc, but now i want to make another separate table, which will feature even more registration options, such as their favorite games, website, other emails etc.
The thing is how would i make a blank field in this table while the user registers, so when it comes updating that setting, its just a simple update query.
Here is the insert code:
Code: Select all
function addNewUser($username, $password, $email, $userid, $name, $bio, $sims3id, $sporeid, $citiesxlid, $sims3, $sims3coll, $sims3wa, $sims3hels, $sims3wt, $sims3cas, $spore, $sporec_c, $sporega, $sporecc, $citiesxl){
$avatar = 'http://jscrgaming.co.uk/images/d4_temp/space/avatars/default.jpg';
$time = time();
/* If admin sign up, give admin user level */
if(strcasecmp($username, ADMIN_NAME) == 0){
$ulevel = ADMIN_LEVEL;
}else{
$ulevel = USER_LEVEL;
}
$q = "INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', '$userid', $ulevel, '$email', $time, '$name', '$bio', '$sims3id', '$sporeid', '$citiesxlid', '0', '$sims3', '$sims3coll', '$sims3wa', '$sims3hels', '$sims3wt', '$sims3cas', '$spore', '$sporecandc', '$sporega', '$sporecc', '$citiesxl', '$avatar')";
return mysql_query($q, $this->connection);
}Code: Select all
function addNewUser($username, $password, $email, $userid, $name, $bio, $sims3id, $sporeid, $citiesxlid, $sims3, $sims3coll, $sims3wa, $sims3hels, $sims3wt, $sims3cas, $spore, $sporec_c, $sporega, $sporecc, $citiesxl){
$avatar = 'http://jscrgaming.co.uk/images/d4_temp/space/avatars/default.jpg';
$time = time();
/* If admin sign up, give admin user level */
if(strcasecmp($username, ADMIN_NAME) == 0){
$ulevel = ADMIN_LEVEL;
}else{
$ulevel = USER_LEVEL;
}
$q = "INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', '$userid', $ulevel, '$email', $time, '$name', '$bio', '$sims3id', '$sporeid', '$citiesxlid', '0', '$sims3', '$sims3coll', '$sims3wa', '$sims3hels', '$sims3wt', '$sims3cas', '$spore', '$sporecandc', '$sporega', '$sporecc', '$citiesxl', '$avatar')";
//fill the user game database with blank data
$sql = "INSERT INTO user_games (username)
values ('$username')";
return mysql_query($q, $this->connection);
return mysql_query($sql, $this->connection);
}
So if anyone would help, it would be very hellpful indeed lol.
James
fyi, you may need explain ur answer, as im not always able to understand, still a newbie at this xD