我正在使用 MySQL 和 PHP 订阅新闻信函脚本。当用户输入电子邮件并单击按钮时,电子邮件被添加到数据库中。
问题是在不输入电子邮件的情况下单击按钮时,数据库正在更新一个空记录。如何停止提交空字段并强制用户输入电子邮件?
这是我的 HTML:
<form id="myForm" action="update.php" method="post">
<input type="hidden" name="action" value="update" />
<input type="text" name="email" id="email" value="Enter your email here" onfocus="if (this.value == 'Enter your email here') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter your email here';}" onwebkitspeechchange="this.value = this.value.replace('Enter your email here','')"; style=" color:#999; font-size:1em;width:200px; font-style:italic; font-family:"Times New Roman", Times, serif;"/>
<input class="button" type="image" src="rss.png" />
</form>