我与用户账户成功登录,我现在要插入记录。 如下文所述,在添加记录方面没有成功。
<?php
session_start();
echo "Welcome: ". $_SESSION[ role ];
?>
<?php
error_reporting(0);
if (!$_POST[ submit ])
{
?
<html>
<body>
<br><br>
<fieldset >
Add a new user
<br>
<br>
<label for= username >Username: </label>
<input type= text name= username id= username />
<label for= password >Password: </label>
<input type= password name= password id= password maxlength="50" />
<form action="<?=$_SERVER[ PHP_SELF ]?>" method="post">
Role:
<br>
<select name="role">
<option value="" selected="selected"></option>
<option VALUE="Administrator"> Administrator</option>
<option VALUE="Secretary"> Secretary</option>
<option VALUE="Employee"> Employee</option>
</select>
<input type= submit name= Submit value= Submit />
</form>
</fieldset>
<table width=100%>
</html>
</body>
<?php
}
else
{
$conn=odbc_connect("employee","","") or die (odbc_errormsg());
if (!$conn)
{
exit
("Connection Failed: " . $conn);
}
$query = "INSERT INTO empTable (empID, password, Role, Days left in MC, Days left in leave) VALUES" .
"( $_POST[username] , $_POST[password] , $_POST[role] , 14, 14)";
$result=odbc_exec($conn,$query) or die ("result error ".odbc_error(). - .odbc_errormsg());
odbc_fetch_row($result);
odbc_close($conn);
}
在点击提交数据库后,当我更新数据库时,没有发现。 为什么如此? A. 备注