已经好几个小时了,我正在尝试添加电子邮件等验证,区域不能为空白,但没有一个对我有用。这是我正在处理的文件
这是 Register.php 文件
<form action="finish.php" method="post"/>
<p>First & Last Name: <input type="text" name="Name"/></p>
<p>Country: <input type="text" name="Country"/></p>
<p>Email Adress <div class="comment">a confirmation email will be sent<br> to you at this address</div><input type="text" name="Email"/></p>
<p>How You Hear About us? <select name="How" id="how" class="how">
<option value="From a Friend">From a Friend</option>
<option value="From Google">From Google</option>
<option value="Advertisements">Advertisments</option>
<option value="Other">Other</option>
</select>
</p>
<input id="submit" type="submit" value="Mail It!" />
</form>
完成.php 文件
<?php
define('DB_NAME', 'temp');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
define ('DB_HOST', 'localhost');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$link) {
die('Could not Connect: ' . mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $link);
if (!$db_selected) {
die('Can\'t use ' .DB_NAME . '; ' .mysql_error());
}
$value = $_POST['Name'];
$value2 = $_POST['Country'];
$value3 = $_POST['Email'];
$value4 = $_POST['How'];
$sql ="INSERT INTO tempr (Name, Country, Email, How) VALUES ('$value', '$value2', '$value3', '$value4')";
if (!mysql_query($sql)) {
die('Error: ' .mysql_error());
}
mysql_close();
?>
表单已连接到数据库,所以如果我添加验证,是否会更难获取数据库中的数据?谁能给我一个添加验证的解决方案?
谢谢