Skip to content

Instantly share code, notes, and snippets.

/subscribe.php
Created Jan 15, 2017

Embed
What would you like to do?
<html>
<head><title>Thanks you for subscribing</title></head>
<body>
<?php
include "config.php";
error_reporting(0);
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$check = mysql_query("SELECT * FROM users WHERE email='$email'");
$check = mysql_fetch_array($check);
$emailcheck = $check['email'];
$hash = md5($email);
if($emailcheck == $email){
echo "<h1>You are already subscribed!</h1>";
}else{
$query = mysql_query("INSERT INTO users(name,email,hash) VALUES('$name','$email','$hash')");
if ($query) {
echo "<h1>You Are Successfully Subscribed to our mailing list. Check you email!</h1>";
$link = 'http://yourdomain.com/subscribe%20and%20unsubsribe/unsubscribe.php?key='.$hash; //change your domain here.
$to="$email"; //change to ur mail address
$strSubject="HackerRahul | Email Subscription";
$message = '<p>Thank you for subscribing '.$name.'.<br>Email: '.$email.'.</p>' ;
$message .= '<p>Click here to unsubscribe your email : <a href="'.$link.'">
Unsubscribe</a></p>' ;
$headers = 'MIME-Version: 1.0'."\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
$headers .= "From: hackerrahul01@gmail.com";
$mail_sent=mail($to, $strSubject, $message, $headers);
} else{
echo mysql_error();
}
}
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.