Monday, December 28, 2015

fill the form data into the database and check the email id if email  registred morethen 7 times then show the message to the user to your email id registred morethen 7 time . please registred another email id.


$con=mysql_connect('localhost','root','') or die(mysql_error());
$db=mysql_select_db('demo') or die(mysql_error());

if($_REQUEST['request']=='enter')
{
               
                $em= $_REQUEST['email'];
                $nm=$_REQUEST['name'];
                $ph=$_REQUEST['phone'];

$sql="SELECT * FROM test";
$rs=mysql_query($sql);
$c=0;
while($data=mysql_fetch_array($rs))
{
                if($data['user_email']==$em)
                {
                                $c++;
                                $id=$data['user_id'];
                                $n=$data['user_name'];
                                $p=$data['user_phone'];
                                $e=$data['user_email'];
                               
                }
                //echo $data['user_email'];
}
}

if($c>6)
{
                echo 'you are registered morethen 7 !<br>';
                echo 'User Id- '.$id.'<br>';
                echo 'User Name- '.$n.'<br>';
                echo 'User Phone- '.$p.'<br>';
                echo 'User Email- '.$e.'<br>';
               
                exit();
}
else
{
                $sql="insert into test(user_name,user_phone,user_email) value('$nm','$ph','$em')";
                if(mysql_query($sql))
                {
                                echo 'Data Saved..!';
                }
}
?>

No comments:

Post a Comment

Featured Post

What is JavaScript? What is the role of JavaScript engine?

  The JavaScript is a Programming language that is used for converting static web pages to interactive and dynamic web pages. A JavaScript e...