2024-05-17 20:57:41 +00:00
|
|
|
<?php
|
|
|
|
session_start();
|
|
|
|
include "db.php";
|
|
|
|
if (isset($_POST["email"])) {
|
|
|
|
$email = $_POST['email'];
|
|
|
|
$emailValidation = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9]+(\.[a-z]{2,4})$/";
|
|
|
|
|
|
|
|
if(empty($email)){
|
|
|
|
echo "
|
|
|
|
<div class='alert alert-warning'>
|
|
|
|
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><b>PLease Fill this field..!</b>
|
|
|
|
</div>
|
|
|
|
";
|
|
|
|
exit();
|
|
|
|
}else{
|
|
|
|
if(!preg_match($emailValidation,$email)){
|
|
|
|
echo "
|
|
|
|
<div class='alert alert-warning'>
|
|
|
|
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>
|
|
|
|
<b>this $email is not valid..!</b>
|
|
|
|
</div>
|
|
|
|
";
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
$sql = "SELECT email_id FROM email_info WHERE email = '$email' LIMIT 1" ;
|
|
|
|
$check_query = mysqli_query($con,$sql);
|
|
|
|
$count_email = mysqli_num_rows($check_query);
|
|
|
|
if($count_email > 0){
|
|
|
|
echo "
|
|
|
|
<div class='alert alert-danger'>
|
|
|
|
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>
|
|
|
|
<b>Email Address is already available</b>
|
|
|
|
</div>
|
|
|
|
";
|
|
|
|
exit();
|
|
|
|
}else{
|
2024-06-08 21:34:04 +00:00
|
|
|
$db_sql = "SELECT * FROM email_info";
|
|
|
|
$db_query = mysqli_query($con, $db_sql);
|
|
|
|
$count_db = mysqli_num_rows($db_query);
|
2024-05-17 20:57:41 +00:00
|
|
|
$sql = "INSERT INTO `email_info`
|
|
|
|
(`email_id`, `email`)
|
2024-06-08 21:34:04 +00:00
|
|
|
VALUES ($count_db + 1, '$email')";
|
2024-05-17 20:57:41 +00:00
|
|
|
$run_query = mysqli_query($con,$sql);
|
|
|
|
echo "<div class='alert alert-success'>
|
|
|
|
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>
|
|
|
|
<b>Thanks for subscribing</b>
|
|
|
|
</div>";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
?>
|