我有以下代码示例 login.php:
<html>
<head>
<title>Modul 15 - Membuat Otentikasi User</title>
</head>
<body>
<h2>Form Login</h2>
Anda belum terdaftar sebagai user ?
[ <a href="register.php">Daftar sekarang</a>]
<br /><br />
<form action="do_login.php" method="post">
<table>
<tr>
<td>ID User</td>
<td><input type="textfield" name="id" maxlength="15" size="25" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="pwd" maxlength="15" size="25" /></td>
</tr>
<tr>
<td> </td>
<td><input type="image" src="login_btn.png" name="login" /></td>
</tr>
</table>
</form>
</body>
</html>
以及处理登录过程的代码为do_login.php:
<html>
<head>
<title>Modul 15 - Membuat Otentikasi User</title>
</head>
<body>
<?php
if (isset($_POST['login']))
{
$id = $_POST['id'];
$pwd = $_POST['pwd'];
$database = "dbxxxxxx";
$hostname = "172.xx.xx.xx";
$port = "50000";
$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;" .
"HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP;UID=$id;PWD=$pwd;";
$conn = db2_connect($conn_string, '', '');
if ($conn)
{
echo "Connection succeeded.";
db2_close($conn);
}
else
{
echo "Connection failed.";
}
}
else
{
echo "Login variable not set !!!";
}
?>
</body>
</html>
代码总是返回“未设置登录变量!!! ”。为什么会这样?我的代码有问题吗?有人能帮助我吗 ...