Skip to content

Instantly share code, notes, and snippets.

@agustinferreira
Created June 24, 2011 19:54
Show Gist options
  • Save agustinferreira/1045539 to your computer and use it in GitHub Desktop.
Save agustinferreira/1045539 to your computer and use it in GitHub Desktop.
<?php
if ($_POST['email'] != "")
{
$email = filter_var($_POST['email'] , FILTER_SANITIZE_EMAIL);
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
{
$result = "The mail you entered is not a valid email address.";
}
$link = mysqli_connect('localhost','root','');
mysqli_select_db($link,'newsletter');
$sql = 'INSERT INTO newsletter SET email = "' . $email . '"';
$sql1 = 'SELECT email FROM newsletter WHERE email = "' . $email . '"';
if (mysqli_query ($link, $sql1))
{
$result = "Your email is alredy registered.";
}
if (mysqli_query ($link, $sql))
{
$result = "Your email has been successfully registered. Thanks for your interest in SABF!";
}
}
else
{
$result = 'Please enter your email address.<br/>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment