Wednesday, July 21, 2010

HOW TO MAKE LOGIN FORM WITH PHP (validate)

Posted by Syarif | Wednesday, July 21, 2010 | Category: |

In this page, I will let you know how to make validation from register.php that you've made before it.

The purpose of this page is to validate the data that user post from register.php so that the data of the user can be sent into the database.
This is the code of validation:




<?php
// Check if passwords match.
if ($_POST[password] != $_POST[password2])
exit("Error - Passwords don't match. Please go back and try again.");

// Assign some variables.
require "connect.php";

// Register him.
$query = mysql_query("INSERT INTO user
(username,email,password) VALUES ('$_POST[username]','$_POST[email]',md5('$_POST[password]'))")
or die ("Error - Couldn't register user.");
echo ("welcome, $_POST[username]! You've been registered");
require "index.php"; /* after the user have registered, then user login into index.php (check the tutorial HOW TO MAKE LOGIN FORM WITH PHP(login)) */
?>




if the user is successful registered, the page will show like:

Currently have 0 comments:


Leave a Reply