为什么这不起作用? [英] why won't this work?

查看:100
本文介绍了为什么这不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试做一个简单的登录页面。但是,即使我输入了一个

正确的用户名和密码,我也会得到你没有被授权!

显示。如果有人可以查看我的代码,看看是否有什么东西是/ b $ b不正确那就太棒了!谢谢。


这是我的html表格:


< HTML>


< HEAD>


< TITLE>指导委员会登录< / TITLE>

< / HEAD>


< center>< form action =" login.php" method =" post">

< table border = 0>

< tr>

< td>< strong> ;用户名:< / strong>< / td>

< td>< input type =" text"命名= QUOT;用户名"大小= QUOT; 10" maxsize =" 10">< / td>

< / tr>

< tr>

< td> < strong>密码:< / strong>< / td>

< td>< input type =" password"名称= QUOT;密码"大小= QUOT; 10" maxsize =" 10">< / td>

< / tr>

< tr>

< td colspan = QUOT; 2英寸align =" center">

< input type =" submit" value ="登录"

< / td>

< / tr>

< / table>

< / form>

< / center>

< / body>

< / html>

这是login.php文件:


< ;?

包括database_info.php;


$ connection = mysql_connect($ server,$ login,$ password)或死(不能

连接。);

$ db = mysql_select_db(" ertcomm",$ connection)或死(无法选择

数据库。)

$ sql =" SELECT ID FROM login WHERE username =''$ username''和

password =''$ password''" ;;

$ sql_result = mysql_query( $ sql,$ connection)或死(无法执行

查询。);

$ num = mysql_numrows($ sql_result);


if($ num == 1)

echo"您现在已登录!" ;;

else if($ num == 0)

echo你没有被授权!;


?>

I am trying to do a simple login page. However, even when I input a
correct user name and password, I get the "You are not authorized!"
display. If anyone could looks over my code and see if anything is
incorrect that would be great! Thanks.

Here is my html form:

<HTML>

<HEAD>

<TITLE>Steering Committee Login</TITLE>
</HEAD>

<center><form action="login.php" method="post">
<table border=0>
<tr>
<td><strong>Username:</strong></td>
<td><input type="text" name="username" size="10" maxsize="10"></td>
</tr>
<tr>
<td><strong>Password:</strong></td>
<td><input type="password" name="password" size="10" maxsize="10"></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="Login">
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
Here is the login.php file:

<?
include "database_info.php";

$connection = mysql_connect($server,$login,$password) or die("Couldn''t
make connection.");
$db = mysql_select_db("ertcomm", $connection) or die("Couldn''t select
database.");
$sql = "SELECT ID FROM login WHERE username=''$username'' and
password=''$password''";
$sql_result = mysql_query($sql,$connection) or die("Couldn''t execute
query.");
$num = mysql_numrows($sql_result);

if ($num == 1)
echo "You are now logged in!";
else if ($num == 0)
echo "You are not authorized!";

?>

推荐答案

connection = mysql_connect(
connection = mysql_connect(


server,


login,


这篇关于为什么这不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆