<?php
//include connect.php page for database connection
Include('connect.php')
//if submit is not blanked i.e. it is clicked.
if(isset($_REQUEST['submit'])!='')
{
if($_REQUEST['name']=='' || $_REQUEST['email']=='' || $_REQUEST['password']==''|| $_REQUEST['repassword']=='')
{
Echo "please fill the empty field.";
}
if (preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/', $email)) {
if (preg_match('/^[a-z\d_]{2,20}$/i', $name)){ // Usename min 2 char max 20 char
if (preg_match("/^[a-z0-9_-]{6,20}$/i", $password)){
if($_REQUEST['repassword']==$_REQUEST['password']){ // Password min 6 char max 20 char
$sql="insert into users(name,email,password) values('".$_REQUEST['name']."', '".$_REQUEST['email']."', '".$_REQUEST['password']."')";
$res=mysql_query($sql);
if($res)
{
Echo "Record successfully inserted";
}
Else
{
Echo "There is some problem in inserting record";
}
}
}
}
}else{
Echo 'Please enter valid data.';
}
?>