Email subscription concept using php and mysqli - Mostlikers

14 August, 2013

Email subscription concept using php and mysqli

This concept user can register our email id to the particular site. for the purpose of when the site administrator post on any messages or updates its directly send the email on subscribe users. coding function used on when user can be register our email id in website form its post and store to the database.

email subscription img
Create blow type table database connect file using on Mysqli connection through the site

  CREATE TABLE `subscripe` (
     `id` int(11) NOT NULL AUTO_INCREMENT,
     `email` VARCHAR( 25 ) NOT NULL


$res1=$conn->query("select * from subscripe where email='$subscriper'");
echo "already subscripe $subscriper this mail";
$res2=$conn->query("insert into subscripe(email) values('$subscriper')");
$to = $subscriper;
$from = "";
$subject = "Email verfications";
$message= "Hello &nbsp;" .$subscriper." <br/><br/><br/>
Thanks to subscripe on Mostlikers"
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
mail($to, $subject, $message, $headers);
echo "thanks to subscripe mostlikers";


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
.login { margin:0 auto; border:dashed 1px #000; width:500px; }
.login form { width:300px; margin:0 auto; }
$conn=new mysqli('localhost','root','','login');
<div class="login">
<form method="post">
<label>Enter your Email ID</label>
<input type="email" name="user" placeholder="Enter your Email" autocomplete="on" required="required" >
<p align="center">
<input type="submit" value="Submit" name="submit" class="submit" id="submit"></p>

Live demo

basically email subscription concept based on feed burner so i provide live demo on my site email subscription. just subscribe here and check the mail.


  1. never trust user input, escape the email address, currently this code is a serious security flaw!!1

  2. Hi, brother karthick,
    I like this tutorial, but can you post a tutorial in which, user cant download file if they are not subscribed user of site

    I mean i want to give downloadable file to user after they subscribe

    give files to user after succesful subscription

    Can you please publish a tutorial about it

    It will really helpful to increse subscribers...
    Thanks ...

    1. Thank you for your comment, sure i will post