PHP

<?php

$name=$_POST[‘name’];
$email=$_POST[’email’];
$phone=$_POST[‘phone’];
$password=$_POST[‘password’];
$cpassword=$_POST[‘cpassword’];
$capcha=$_POST[‘capcha’];
$con=mysql_connect(“localhost”,”root”,””);
mysql_select_db(“itexam”,$con);
$sql=”select * from studentrecord where email=’$email'”;
$result=mysql_query($sql);
$num=mysql_num_rows($result);
$regex = “^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$^”;
$errormsg=array();

if($capcha==”” )

{

$errormsg=”Plase Enter Your Answer”;

}

else if($capcha==4)

{

$errormsg=””;
}

else
{

$errormsg=”incorrect answer”;

}

if($name==””)

{

$errormsg=”enter your Name “;

}
if($email==””)

{

$errormsg=”enter your email “;

}

if($phone==””)

{

$errormsg=”enter your phone “;

}

if($password==””)

{

$errormsg=”enter your password “;

}

if(!preg_match( $regex, $email ))

{

$errormsg=”enter your valid email”;

}

if($password!==$cpassword)

{

$errormsg=”password did not match”;

}

if(empty($errormsg))

{

if($num>0)
{

echo “<font color=red>email id is already used please use another email id</font>”;

}

else

{
$sql1=”insert into studentrecord(name,email,phone,password)values(‘$name’,’$email’,’$phone’,’$password’)”;

mysql_query($sql1);

echo “<font color=red>successfully registered </font>”;

}
}

else

{
echo”<font color=red> $errormsg </font>”;
}
?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s