所以我已经受够了这个任务,我仍然试图让这个登录页面真正登录,它应该是一个使用 $_SERVER['PHP_SELF'] 的自我引用登录页面,但它仍然不会做任何事情
<center>
<h2>Please log in</h2>
<p>Enter your login ID and password to connect to this system<br/>
</p>
<form name="Input" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<table border="1" bgcolor="black" cellpadding="10" >
<tr>
<td><strong>Username:</strong></td>
<td><input type="text" name="login" value="" size="20" placeholder="Username" /></td>
</tr>
<tr>
<td><strong>Password:</strong></td>
<td><input type="password" name="password" value="" size="20" placeholder="**********"/></td>
</tr>
</table>
<table border="0" cellspacing="15" >
<tr>
<td><input type="submit" value = "Login" /></td>
<td><input type="reset" value = "Reset" /></td>
</tr>
</table>
</form>
<p>
Please wait after pressing <strong>Log in</strong>
while we retrieve your records from our database.<br/>
<em>(This may take a few moments)</em>
</p>
<hr/>
</center>
</body>
</html>
<?php //embed in a page with a two input box (named id and pass) form
require "functions.php";
$login = $_POST['id'];
$password = $_POST['password'];
$conn = db_connect();
$sql = "SELECT first_name, last_name, email_address, last_access FROM users WHERE id = '".$login."' AND password= '".$password."'";
$results = pg_query($conn, $sql);
if(pg_num_rows($results)){ //not zero means something was found
//user found, use pg_fetch_result to pull user specific info to displa
}else{
//user not found, check for just login id
$sql = "SELECT * FROM users WHERE id = '".$login."'";
$results = pg_query($conn, $sql);
if(!pg_num_rows($results)){ //user not found, empty $login to unstick it
$login = ""; //when echo’’ed in the form
}
}
这是我已经拥有的代码
这是我老师在课堂上给的代码,但它仍然不起作用
我也不知道把欢迎信息放在哪里或如何让它显示出来。
我试过用欢迎消息制作一个welcome.php 文件,但它仍然不起作用
我只是想念一些东西
(另外,如果你选择评论不要粗鲁,我很挣扎)
谢谢
?>