我已经在这个网站和互联网上搜索了一个很好的简单解决方案,关于如何检查电子邮件是否被两次输入到我的数据库以及它是否是有效的电子邮件。我一直无法找到一个简单的解决方案。这是我的表格和php。提前致谢
<div class="email-survey">
<?php if(isset($success)) { ?>
<div class="success_survey">Thanks you! Your survey has been submitted</div>
<?php } ?>
<?php if(isset($error)) { ?>
<div class="error_survey">
<?php echo $error; ?>
</div>
<?php } ?>
<form name="settings" action="/survey-confirm.php" method="post">
<input type="text" name="email" /> <br />
<input type="submit" name="submit" value="submit" />
</form>
</div>
require_once($_SERVER['DOCUMENT_ROOT'] . '/includes/system/init.php');
if(isset($_POST['submit'])) {
$email = $_POST['email'];
if(empty($_POST['email'])) {
$error = "Please enter a valid email";
}else{
$success = true;
mysql_query("INSERT INTO survey_email
(email) VALUES('".$_POST['email']."' ) ")
or die(mysql_error());
header('Location: /survey-email-confirm.php');
}
}
?>