This tutorial we will see how to send a activation mail after signup using php
Create table mailinsert
mailact.php
verify.php
Create table mailinsert
CREATE TABLE IF NOT EXISTS `mailinsert` (
`sno` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`email` varchar(50) NOT NULL,
`password` varchar(50) NOT NULL,
`city` varchar(50) NOT NULL,
`status` int(11) NOT NULL,
`code` varchar(50) NOT NULL,
PRIMARY KEY (`sno`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
mailact.php
<?php
$con=mysql_connect("hostname","username","password");
mysql_select_db("databasename",$con);
$name=$_POST['name'];
$email=$_POST['email'];
$password=$_POST['password'];
$city=$_POST['city'];
$status=1;
$code=rand();
if(isset($_POST['submit'])){
$sql="insert into mailinsert(sno,name,email,password,city,status,code)values('','$name','$email','$password','$city','$status','$code')";
$res=mysql_query($sql);
if($res)
{
echo "inserted";
$subject = "Email Verification - Codetipz";
$message = "Hi $name<br /> <br />
Thankyou for registration with Codetipz. Please <a href='http://yourwebsite.com/verify.php?code=$code'>Click Here to verify your Email ID</a> <br /><br />
Best Regards<br />
Justcourse
";
$cemail="admin@codetipz.blogspot.in";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
// Additional headers
$headers .= 'From: '.$cemail . "\r\n";
$headers .= 'Reply-To: '.$cemail . "\r\n";
$to = $email;
if(mail($to, $subject, $message, $headers))
{
echo "<script>alert('You Have Successfully Registered, An Verification Email Sent To Your Email. Please Verify Your Email And Access Your Account')</script>";
}
}
}
?>
<style type="text/css">
table {
background:#BADCE0;
border-radius:10px;
margin-top:150px;
}
</style>
<form method="post" action="">
<table width="200" align="center">
<tr>
<td>Name</td>
<td><input type="text" name="name" id="name"></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" name="email" id="email"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="password" id="password"></td>
</tr>
<tr>
<td>City:</td>
<td><select name="city" id="city">
<option value="">Select City</option>
<option value="city1">city1</option>
<option value="city2">city2</option>
<option value="city3">city3</option>
<option value="city4">city4</option>
</select>
</td>
</tr>
<tr>
<td align="center" colspan="2"><input type="submit" name="submit" id="submit" value="Register"></td>
</tr>
</table>
</form>
verify.php
<?php
$con=mysql_connect("hostname","username","password");
mysql_select_db("databasename",$con);
$code=$_GET['code'];
$sql1 = "select * from mailinsert where code = '$code'";
$result = mysql_query($sql1);
if(mysql_num_rows($result) != 0)
{
$sql="update mailinsert set status='0' where code='$code'";
$upd=mysql_query($sql);
if($upd)
{
echo "<script><alert><h3>Your Email Has Been Succssfully Verified. Please Login And Access Your Account</h3></alert></script>";
}
}
else
{
echo "invalid request";
}
?>
09:04
Share:
0 comments: