User Signup/Register Tutorial (Basic)

First thing were going to do is make a Mysql table which will basically store all user names, and passwords . Logon to PhpMYadmin on the Cpanel, and create a database name such as “testdb” . Then inside the database, create a table and name is “users” and have 4 colums for it.

The 4 columns for the “users” table inside the “testdb” should be setup like the following :

Okay,noww thats done. Create a notepad doc And paste this code inside

<form action="make.php" method="post">
Username Desired: <input type="text" name="username" size="10">
Password Desired: <input type="password" name="password" size="10">
E-mail: <input type="text" name="email" size="10">
<input type="submit" value="submit" name="submit">
</form>

Now save this as signup.html

Then make another notepad doc and paste the following code

<?
//replace username and password with your mysql name and password
$conn = mysql_connect("**localhost**","**USERNAME**","**PASSWORD**");

//select the database
$db = mysql_select_db("testdb");

$username = $_POST["username"];
$password = $_POST["password"];
$email = $_POST["email"];

//insert the values
$result= MYSQL_QUERY("INSERT INTO users (id, username, password, email)".
   "VALUES ('NULL', '$username', '$password', '$email')");
   
echo "Your name and password have been submitted into our database :)";
?> 

And save it as make.php .

Now make yet another notepad doc and paste the following

<form action="getin.php" method="post">
Username: <input type="text" name="username" size="10">
Password: <input type="password" name="password" size="10">
<input type="submit" value="submit" name="submit">
</form>

save this as login.html .

Finally,one more blank notepad doc and paste the following

<?
$conn = mysql_connect("**localhost**","**USERNAME**","**PASSWORD**");
$db = mysql_select_db("testdb");

$username = $_POST["username"];
$password = $_POST["password"];

$result = MYSQL_QUERY("SELECT * from users WHERE username='$username'and password='$password'")
   or die ("Name and password not found or not matched");

$worked = mysql_fetch_array($result);

$username = $worked[username];
$password = $worked[password];
$email = $worked[email];

if($worked)
   echo "Welcome $user! Your e-mail address is $email"; 
?>

and call it getin.php .

Now where it says USERNAME, PASSWORD and Local host rename to the phpmyadmin username,and password, and local host needs to be changed to what it says under Mysql management link in PHPmyadmin (should be somthing like **mysql4.000webhost.com **)
Finally done,now go to the Cpanel on your account,and go to the filemanager, go to public Html, and upload all four of these files there. and then finally view the signup.html page,and signup and test it all out.

Hopefully this helps you to understand the basic user system, of course you can devlop on this,and create an excellent user login etc.

1 Like

Several things I do not like about this:

  1. You do not encrypt the passwords.
  2. You do not slash the quotes.
  3. You do not record their log in through any means (PHPSESSIONID, Cookies, etc.)

As i said,very basic. Your welcome to expand upon it.

It might be basic, but you might just want to add md5 encryption on the password, as it currently is very insecure and nobody wants their information stolen do they?