我是新來的PHP,我試圖註冊用戶代碼,但它不能正常工作。如果我註釋掉頭('location:login.php');然後它將數據保存在數據庫中,如果我取消註釋此頭('location:login.php');那麼它不會將數據保存在數據庫中並打開登錄頁面。php註冊表問題
<html>
<head>
<title>records...</title>
</head>
<body>
<form action="registration.php" method="post">
<table border="1" align="center" cellspacing="2">
<tr>
<th>ID</th>
<td><input type="text" name="id"></td>
</tr>
<tr>
<th>username</th>
<td><input type="text" name="username"></td>
</tr>
<tr>
<th>password</th>
<td><input type="password" name="password"></td>
</tr>
<tr>
<th>email</th>
<td><input type="text" name="email"></td>
</tr>
<tr>
<th>contact</th>
<td><input type="text" name="contact"></td>
</tr>
<tr>
<td colspan="2" align="center" style="color: red"><input type="submit" name="submit" value="submit"></td>
</tr>
</table>
</form>
<?php
error_reporting(0);
if(isset($_REQUEST["submit"])){
//header('location:login.php');
require 'conn.php';
$id=$_REQUEST['id'];
$username=$_REQUEST['username'];
$password=$_REQUEST['password'];
$email=$_REQUEST['email'];
$contact=$_REQUEST['contact'];
$query="insert into dhr values('$id','$username','$password','$email','$contact')";
$result= mysql_query($query);
if($result>0){
echo"insert successfully..";
} else {
echo "not inserted". mysql_error();
}
}
?>
</body>
</html>
能否請您給我解釋一下您的具體問題? –
您能否指定錯誤或問題? – Dave
...你寫了這段代碼嗎?我非常懷疑它,如果你這樣做,那麼請不要在不知道它做什麼的情況下添加代碼,'header(location:...);'重定向用戶,所以當然如果你不發表評論,它會重定向用戶,因爲它應該是 – Epodax