<center></center>
<form name="registration_form" method="post" action="register.php"
onsubmit="return Validate();">
<table border="0" align=center>
<tr>
<td><font size=5><center>Name: </center></font></td><td><input type="text" name="names"></td>
</tr>
<tr>
<td><font size=5><center>Email: </center></font></td><td><input type="text" name="email"></td>
</tr>
<tr>
<td><font size=5><center>Username: </center></font></td><td><input type="text" name="username"></td>
</tr>
<tr>
<td><font size=5><center>Password: </center></font></td><td><input type="password" name="password"></td>
</tr>
<tr>
<td><font size=5><center>Password Confirmation: </center></font></td><td><input type="password" name="password_confirmation"></td>
</tr>
<tr>
<td><font size=5><center>Phone Number: </center></font></td><td><input type="text" name="phone_number"></td>
</tr>
<tr>
<td><font size=5><center>Click to Register </center></font></td><td><input type="submit" value="Register"></td>
</tr>
</table>
</form>
</center>
<br>
<?php
session_start();
include ('config.php');
$names = $_POST["names"];
$email = $_POST["email"];
$phone_number = $_POST["phone_number"];
$username = md5($_POST["username"]);
$password = md5($_POST["password"]);
$checkuser = mysql_query("SELECT email FROM users WHERE email='$email'");
$email_exist = mysql_num_rows($checkuser);
if($email_exist > 0){
unset($email);
include 'registration_form.php';
echo "<script>alert('Duplicate entry on email: ".$_POST['email'].". Please use another email.')</script>";
exit();
}
$checkuser = mysql_query("SELECT username FROM users WHERE username='$username'");
$username_exist = mysql_num_rows($checkuser);
if($username_exist > 0){
unset($username);
include 'registration_form.php';
echo "<script>alert('Duplicate entry on username: ".$_POST['username'].". Please use another username.')</script>";
exit();
}
$sql = "INSERT INTO users (id_user, names, email, phone_number, username, password) VALUES ('','$names', '$email', '$phone_number', '$username', '$password')";
$result = mysql_query($sql,$con);
if(mysql_error())
{
}
else {
}
if(!$result){
die('Error: '. mysql_error());
}
else
{
include ("success_user.php");
echo "<script>User $names Succesfully Added!</script>";
}
?>
Guys how will i make it interactively warns when the password confirmation will not match. and check if null field it won't save. Thanks in advance guys.