我正试图从我的表单中阻止一点垃圾邮件。这是一个电子邮件列表,只需将框中的任何文本提交到我的数据库中即可。有没有办法让我检查用户是否在字段中添加了@?
echo '<style type="text/css">';
include 'style.css';
echo '</style>';
if( $_POST )
{
$con = mysql_connect("localhost","flickey_emails","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("flickey_emailsubscribe", $con);
$users_email = $_POST['email'];
$users_email = htmlspecialchars($users_email);
$query = "INSERT INTO `flickey_emailsubscribe`.`emails` (`id`, `email`) VALUES (NULL, '$users_email');";
mysql_query($query);
echo "<h2>Thanks for joining the email list!</h2>";
mysql_close($con);
HTML
<form action="contact.php" method="post">
Email: <input type='text' name='email' id='email' /><input type='submit' value='Submit' />
</form>