我是 PHP 新手,我有 html 页面,需要用户提供用户名和密码才能进入聊天页面
html page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="stylesheet" type="text/css" href="Registerstyle.css">
<title>اسجل دخولك الى الشات</title>
</head>
<body>
<div id = "page">
<div id = "header">
</div>
<div id = "container" dir = rtl>
<div id = "menu">
<ul>
<li><a href="#">تسجيل الدخول</a></li>
<li><a href="#">استرجاع كلمة المرور</a></li>
<li><a href="#">######</a></li>
<li><a href="#">######</a></li>
</ul>
</div>
<div id = "midofcontainer">
<div id = "text">
اسم المستخدم <br><br>
كلمة المرور
</div>
<div id = "form">
<form name="log" method="GET" action="login.php">
<input type="text" name="usr" id="usr" style="width: 242px"></input><br><br>
<input type="password" name="pwd" style="width: 242px"></input><br><br>
<input type="submit" style="width: 78px" value="تسجيل الدخول">
<input type="reset" style="width: 78px" value="مسح">
</div>
</div>
</div>
<div id = "footer">
</div>
</div>
</body>
</html>
这是我的 php 文件,它将检查来自 html 的值
<?php
require 'connect.inc.php';
$usr = $_GET['usr'];
$pwd = $_GET['pwd'];
$table_name = 'user';
$query = "SELECT * FROM $table_name" ;
$query_run = mysql_query($query);
while($rows = mysql_fetch_array($query_run))
{
if ($rows['username'] == $usr and $rows['password'] == $pwd)
{
include ('chatArea.php');
exit();
}
else
include_once ('log.html');
}
?>
现在我想要的是当它if ($rows['username'] == $usr and $rows['password'] == $pwd)
返回true
时打开一个新的 php 页面并将用户名传递给页面我希望能让我的问题清楚,对不起我的英语不好