As i have been working on my web site i have been learning php scripting.
well one of the things that i wanted to learn how to do was build a user account login and creation script.
And as i am builing this scipt i kept comeing up with new ideas.

So this is how it goes.

A. The users regisers an accont with there name password and email address.

1. There name and password and email address are added to our
account
database under the table users and in the username password and
email entries.

2. A folder is then created with the same name as the name they
registered with.

3. A default html templet is then copyed over to there account folder
along with all pics ect ect.

The reason behind a createing a username account folder and copying over a default memebers templet is so the users can customize the look and feel of there page plus keep other info only relavent to that user.

B. The users then login.

1.When the users login to the system they are redirected to the folder
holding there index.html file that relavent to there login name
but only if there password matches
up with the one stored in our password entrie in our mysql db.



A. Signup.html

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http&#58;//www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Wolf Account Creation</title>
</head>

<body>
<form action="signup.php" method="post">
   

Username Desired&#58; 
   
<input type="text" name="username" size="25">
</p>
   

Password Desired&#58; 
   
<input type="password" name="password" size="25">
</p>
  E-mail&#58;   
   
<input type="text" name="email" size="25">
   

 <input type="submit" value="submit" name="submit">
</p>
</form>
</body>
</html>

A. Signup.php

Code:
<?
//login would be replaced with your root login name and pass your root password
$conn = mysql_connect&#40;"localhost","rootusername","rootpassword"&#41;;

//select the database
$db = mysql_select_db&#40;"account"&#41;;

$username = $_POST&#91;"username"&#93;;
$password = $_POST&#91;"password"&#93;;
$email = $_POST&#91;"email"&#93;;

//insert the values
$result= MYSQL_QUERY&#40;"INSERT INTO users &#40;id, username, password, email&#41;".
   "VALUES &#40;'NULL', '$username', '$password', '$email'&#41;"&#41;;

umask&#40;011&#41;;
mkdir&#40;"$username", 0777&#41;;
mkdir&#40;"$username/images", 0777&#41;; 

$source_file = "/home/comptux/public_html/wolf-create/member/index.html";
$destination_file = "/home/comptux/public_html/wolf-create/$username/index.html";
copy &#40;$source_file, $destination_file&#41;;


$source_file1 = "/home/comptux/public_html/wolf-create/member/images/background.png";
$destination_file1 = "/home/comptux/public_html/wolf-create/$username/images/background.png";
copy &#40;$source_file1, $destination_file1&#41;;

$source_file2 = "/home/comptux/public_html/wolf-create/member/images/logo.png";
$destination_file2 = "/home/comptux/public_html/wolf-create/$username/images/logo.png";
copy &#40;$source_file2, $destination_file2&#41;;

$source_file3 = "/home/comptux/public_html/wolf-create/member/images/button.png";
$destination_file3 = "/home/comptux/public_html/wolf-create/$username/images/button.png";
copy &#40;$source_file3, $destination_file3&#41;;

$source_file4 = "/home/comptux/public_html/wolf-create/member/images/bbar.png";
$destination_file4 = "/home/comptux/public_html/wolf-create/$username/images/bbar.png";
copy &#40;$source_file4, $destination_file4&#41;;

$source_file5 = "/home/comptux/public_html/wolf-create/member/images/bar.png";
$destination_file5 = "/home/comptux/public_html/wolf-create/$username/images/bar.png";
copy &#40;$source_file5, $destination_file5&#41;;

$source_file6 = "/home/comptux/public_html/wolf-create/chmodi.php";
$destination_file6 = "/home/comptux/public_html/wolf-create/$username/chmodi.php";
copy &#40;$source_file6, $destination_file6&#41;;

chmod&#40;"$username", 0777&#41;; 
chmod&#40;"$destination_file", 0777&#41;; 
echo "All seems to be good";
?>

B. login.html

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http&#58;//www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Wolf Login</title>
</head>

<body>
<form action="login.php" method="post">


Username&#58; 
<input type="text" name="username" size="25">
</p>


Password&#58; 
<input type="password" name="password" size="25">
</p>


<input type="submit" value="Log in" name="submit">
</p>
</form>
</body>
</html>

B. Login.php

Code:
<?
$conn = mysql_connect&#40;"localhost","rootusername","rootpassword"&#41;;
$db = mysql_select_db&#40;"account"&#41;;

$username = $_POST&#91;"username"&#93;;
$password = $_POST&#91;"password"&#93;;

$result = MYSQL_QUERY&#40;"SELECT * from users WHERE username='$username'and password='$password'"&#41;
   or die &#40;"Name and password not found or not matched"&#41;;

$worked = mysql_fetch_array&#40;$result&#41;;

$username = $worked&#91;username&#93;;
$password = $worked&#91;password&#93;;
$email = $worked&#91;email&#93;;

if&#40;$worked&#41;
   header&#40;"Location&#58; http&#58;//www.comtuxaps.com/$username/index.html"&#41;; 
?>
Some other things i need to add are account verifacation by e-mail.
and make it so no 2 or more users can create a account useing the same username.
Because right now to can create 30 users all with same account name i am not sure but i think the mysql username entries just end up getting over written.
And i need to studie file/folder ownership and pemissions so only the file/folder owner can make modifacations to there own stuff.

And just incase anyone is wonder i know this is all basic basic php code but what do you want from me i have only been useing php for like 5 days now.

Ok there you go it is gitting late i will exsplane this in more detail some other time.