SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Jun 2, 2001, 05:50 #1
- Join Date
- Jun 2001
- Posts
- 10
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
How to create a table when regist....
Hello all
I have one registration page which allows a new user can regist himself an username and a password. These username and password will be stored into a table of a database.
Now I want is that when that user regists himself, he also creates a data table for himself. Then each time he logs in, he can insert, delete or edit his table. Could you please tell me how to do that.....
Normally I can use SQL with foreign key, but in MySQL, this is not supported.
Thank you very much for help
john
-
Jun 2, 2001, 07:49 #2
- Join Date
- Dec 2000
- Location
- Idaho, USA
- Posts
- 452
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
We're using PHP right? Not a problem!
PHP Code:$username = "Alex Stanton";
$age = 14;
$occupation = "Server Side Dev/Database Admin";
$password = "favoritenumber";
if(ereg("_", $username)){
echo("No Underscores Allowed In Username");
} else {
$tabe_name = ereg_replace(" ". "_", $username);
$sql = "INSERT INTO users SET username='$username', age='$age', occupation='$occupation', password=PASSWORD('$password'), active='1'";
if(!mysql_query($sql)){
echo("Database Error");
} else {
$sql = "CREATE TABLE $table_name (id INT not null AUTO_INCREMENT, test TEXT , PRIMARY KEY (id))";
if(!mysql_query($sql)){
echo("Database Error");
} else {
echo("Thank You For Signing Up");
}
}
PHP Code:
// include.inc
function remove_user_table($username){
$table_name = ereg_replace(" ", "_", $username);
if(!mysql_query(DROP TABLE $table_name)){
return false;
} else {
return true;
}
}
// modify.php
if($action=="delete"){
$sql = "UPDATE users SET active='0' WHERE username='$username'";
if(!mysql_query($sql)){
echo("Database Error");
} else {
if(!remove_user_table($username)){
echo("Database Error");
} else {
echo("$username Successfully Deleted");
}
}
}
Regards,
AlexBlamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.
Exbabylon- Professional Internet Services
-
Jun 2, 2001, 18:50 #3
- Join Date
- Jun 2001
- Posts
- 10
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thank you very much for your help
john
Bookmarks