web: prepared webpage for publishing
* renamed admin directory to php because adblocker blocked ajax * don't refresh page when pressing enter * improved english * added db_config for live page
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
header('Content-type: application/json');
|
||||
$response_array['status'] = 'error';
|
||||
|
||||
$email = $_POST["email"];
|
||||
$regex = "/^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/";
|
||||
if (preg_match($regex, $email))
|
||||
{
|
||||
include("db_config.php");
|
||||
|
||||
$link = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
if (mysqli_connect_errno())
|
||||
{
|
||||
exit();
|
||||
}
|
||||
|
||||
$email = mysqli_real_escape_string($link, $email);
|
||||
|
||||
if (mysqli_query($link, "INSERT INTO " . $tabename . " (`id`, `mail`) VALUES (0, '$email')"))
|
||||
{
|
||||
$response_array['status'] = 'success';
|
||||
}
|
||||
|
||||
$link->close();
|
||||
}
|
||||
else
|
||||
{
|
||||
$response_array['status'] = 'error_invalid_email';
|
||||
}
|
||||
|
||||
echo(json_encode($response_array));
|
||||
?>
|
||||
Reference in New Issue
Block a user