PHP数据库的mysql_query("SELECT * FROM list WHERE name=这里怎么写能让name等于我在输入框写的值
<html><head><linkrel="stylesheet"type="text/css"href="../style1.css"/></head><body><f...
<html>
<head>
<link rel="stylesheet" type="text/css" href="../style1.css" />
</head>
<body>
<form action="check.php" method="post">>
name:
<input type="text" name="t1" /><br />
password:
<input type="text" name="t2" />
<input type="submit"/></font>
</form>
</body>
</html>
=================================================
check.php
<html>
<head>
<link rel="stylesheet" type="text/css" href="../style1.css" />
<script type="text/javascript">
function login(){
var i1=<?php echo $_POST["t2"]; ?>;
var i2=<?php
$con = mysql_connect("localhost","root","");
if(!$con)
{
die('Could not connect: '. mysql_error());
}
mysql_select_db("my_db", $con);
$result = mysql_query("SELECT * FROM list WHERE name=$_POST["t1"]" );
$row = mysql_fetch_array($result);
echo "".$row['password'].""; ?>
if(i1==i2){
alert("password is right")
}
}
</script>
</head>
<body>
<p id="warn" style="display: none;"> </p>
<form name="form1">
<input type="button" value="checking..." onclick="login()"/></font>
</form>
</body>
</html>
=================================================
table list
id int
name text
password int
怎么在第一个网页输入用户名和密码post给第二个网页,通过输入的用户名查询该name在数据库里的密码,并和之前输入的密码对比呢
$result = mysql_query("SELECT * FROM list WHERE name=$_POST["t1"]" );这个$_POST["t1"]貌似不对 小白求救啊 作业交不上了 展开
<head>
<link rel="stylesheet" type="text/css" href="../style1.css" />
</head>
<body>
<form action="check.php" method="post">>
name:
<input type="text" name="t1" /><br />
password:
<input type="text" name="t2" />
<input type="submit"/></font>
</form>
</body>
</html>
=================================================
check.php
<html>
<head>
<link rel="stylesheet" type="text/css" href="../style1.css" />
<script type="text/javascript">
function login(){
var i1=<?php echo $_POST["t2"]; ?>;
var i2=<?php
$con = mysql_connect("localhost","root","");
if(!$con)
{
die('Could not connect: '. mysql_error());
}
mysql_select_db("my_db", $con);
$result = mysql_query("SELECT * FROM list WHERE name=$_POST["t1"]" );
$row = mysql_fetch_array($result);
echo "".$row['password'].""; ?>
if(i1==i2){
alert("password is right")
}
}
</script>
</head>
<body>
<p id="warn" style="display: none;"> </p>
<form name="form1">
<input type="button" value="checking..." onclick="login()"/></font>
</form>
</body>
</html>
=================================================
table list
id int
name text
password int
怎么在第一个网页输入用户名和密码post给第二个网页,通过输入的用户名查询该name在数据库里的密码,并和之前输入的密码对比呢
$result = mysql_query("SELECT * FROM list WHERE name=$_POST["t1"]" );这个$_POST["t1"]貌似不对 小白求救啊 作业交不上了 展开
2个回答
展开全部
$result = mysql_query("SELECT * FROM list );
$row = mysql_fetch_array($result);
$name= $row['name'];
$pwd=$row['password'];
if($pwd=$_POST["t2"]){
echo "密码正确";
}else{
echo "密码错误";
}
另外,你的密码表单域应该写成密码表单域。
<input name="t2" type="password" id="pwd" />
也可以先判断用户名再比较密码。
祝你成功,望采纳!
$row = mysql_fetch_array($result);
$name= $row['name'];
$pwd=$row['password'];
if($pwd=$_POST["t2"]){
echo "密码正确";
}else{
echo "密码错误";
}
另外,你的密码表单域应该写成密码表单域。
<input name="t2" type="password" id="pwd" />
也可以先判断用户名再比较密码。
祝你成功,望采纳!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询