我有我的 registerUsers.html 如下
<html>
<head>
<title>userlogin</title>
</head>
<body>
<h1><center>User login</center></h1>
<p>
<strong><font color= "green"> REGISTER HERE </font></strong>
<br>
<form method="post" action="registerUsers.php">
<p><strong>ID:</strong><br/>
<input type="text" name="id"/></p>
<p><strong>FirstName:</strong><br/>
<input type="text" name="firstname"/></p>
<p><strong>Lastname:</strong><br/>
<input type="text" name="lastname"/></p>
<p><strong>Username:</strong><br/>
<input type="text" name="username"/></p>
<p><strong>Password:</strong><br/>
<input type="password" name="password"/></p>
Admin <input type="radio" name="type" value="admin" /><br />
Author <input type="radio" name="type" value="author" checked="checked"/>
<p><input type="submit" name="submit" value="Register"/></p>
</form>
</p>
</body>
</html>
和 registerUsers.php 如下
<?php
include("dbconnect.php");
$con=new dbconnect();
$con->connect();
if(isset($_POST['submit'])) {
$type=0;
if($_POST['type'] =="admin")
$type = 1;
if($_POST['type'] =="author")
$type = 0;
$sSql = "INSERT INTO users
( id, first_name, last_name,username, password, type)
VALUES ('$_POST[id]', '$_POST[firstname]', '$_POST[lastname]', '$_POST[username]', PASSWORD(\"$_POST[password]\"), $type)";
mysql_query($sSql);
echo '<h2>USER REGISTERED</h2><br />';
}
?>
当我选择“作者”单选按钮时,没有任何内容存储在数据库的“类型”变量中。如果我选择管理员,“管理员”存储在类型变量中。我该如何解决这个问题,以便“作者”可以存储在数据库的“用户”表中。
任何想法或帮助将不胜感激。谢谢!