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>