Saturday 28 February 2015

PHP script for email verification or confirmation in php?

(1) first create table user:

create table user
(id int primary key auto_increment,

name varchar(200),
email varchar(200),
phone varchar(200),
password varchar(200),
com_code varchar(200));


(2)write code for connect.php file:

<?php

$con=mysql_connect("localhost","root","");
mysql_select_db("itexamtime",$con) or die(mysql_error());

?>

(3)write code for registerform.php file:
<?php


echo '<form action="insert1.php"   method="post">
      Name<input type=text name="name">
 Email<input type=email name="email">
 phone  <input type=text    name="phone">
 password<input type=password name="password">
 <input  type=submit  name=submit value=submit>';

 
?>

(4)write code for insert1.php file:



<?php
$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$password=$_POST['password'];
$com_code=md5(uniqid(rand()));
include_once("connect.php");

$sql="insert into user(name,email,phone,password,com_code)values('$name','$email','$phone','$password','$com_code')";

$result=mysql_query($sql) or die(mysql_error());

if($result)
  {
   $to = $email;
   $subject = "Confirmation from TutsforWeb to $username";
   $header = "ItexamTime: Confirmation LInk";
 
   $message .= "http://funmoviemasti.com/confirm.php?passkey=$com_code";

   $sentmail = mail($to,$subject,$message,$header);

   if($sentmail)
            {
   echo "Your Confirmation link Has Been Sent To Your Email Address.";
   }
   else
         {
    echo "Cannot send Confirmation link to your e-mail address";
   }

}

?>

(5)write code for confirm.php file:

<?php

include_once("connect.php");

$passkey = $_GET['passkey'];

 $sql="update user set com_code='1'  where com_code='$passkey'";

$result=mysql_query($sql) or die(mysql_error());

if($result)

{


echo "your account is active ";




}



?>







No comments:

Post a Comment