【发布时间】:2015-03-31 13:45:18
【问题描述】:
美好的一天!我正在建立一个在线学习网站,每个用户都有自己的帐户,他们可以通过点击“我的个人资料”链接查看他们的个人资料。我已尝试将其连接以登录,但它直接进入个人资料页面。这是我的instructor_profile.php 代码,如何将讲师菜单中的链接(我的个人资料)连接到个人资料页面?谢谢。
<?php
mysql_connect("localhost", "root", "root");
mysql_select_db("db_elearning");
$idNumber = $_REQUEST['idNumber'];
$get = mysql_query("SELECT * FROM tbl_instructor WHERE idNumber = '$idNumber'");
$get2 = mysql_fetch_assoc($get);
$username = $get2['username'];
$password = $get2['password'];
$lastName = $get2['lastName'];
$firstName = $get2['firstName'];
$middleName = $get2['middleName'];
$location = $get2['location'];
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body,td,th {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 18px;
}
</style>
</head>
<body>
<p> </p>
<p> </p>
<p><br />
</p>
<form id="form1" name="form1" method="post" action="">
<p align="center"><strong>Instructor's profile</strong> </p>
<table border="0" width="30%" align="center">
<tr><td width="40%">
<label for="username">Username</label> </td> <td>
<input type="text" name="username" id="username" value="<?php echo $username;?>" />
</td> </tr>
<tr><td width="40%">
<label for="password">Password</label> </td> <td>
<input type="text" name="password" id="password" value="<?php echo $password;?>" />
</td> </tr>
<tr><td width="40%">
<label for="lastName">Last name</label> </td> <td>
<input type="text" name="lastName" id="lastName" value="<?php echo $lastName;?>" />
</td> </tr>
<tr><td width="40%">
<label for="firstName">First name</label> </td> <td>
<input type="text" name="firstName" id="firstName" value="<?php echo $firstName;?>" />
</td> </tr>
<tr><td width="40%">
<label for="middleName">Middle name</label> </td> <td>
<input type="text" name="middleName" id="middleName" value="<?php echo $middleName;?>" />
</td> </tr>
</td> </tr>
<tr><td width="40%">
<label for="location">Location</label> </td> <td>
<input type="text" name="location" id="location" value="<?php echo $location;?>" />
</td> </tr>
</table>
</form>
</body>
</html>
这是讲师的登录,它直接进入用户的个人资料
<?php
$username = $_POST['username'];
$password = $_POST['password'];
if($username && $password){
mysql_connect("localhost", "root", "root") or die("Connection to server failed!");
mysql_select_db("db_elearning");
$query = mysql_query("SELECT * FROM tbl_instructor WHERE username ='$username'");
$numrows = mysql_num_rows($query);
if($numrows != 0){
while($row = mysql_fetch_assoc($query)){
$idNumber = $row['idNumber'];
$dbname = $row['username'];
$dbpassword = $row['password'];
}
if($username==$dbname){
if($password==$dbpassword){
header("location:instructor_frame.html");
if ($numrows ==1){
header("location:instructor_profile.php?idNumber=$idNumber");
}else{
echo "Your password is incorrect!";
}
}else{
echo "Your name is incorrect!";
}
}else{
echo "This name is not registered!";
}
}else{
echo "You have to type a name and password!";
}
}
?>
【问题讨论】:
-
使用 GET 代替 Request..
-
我很困惑它不起作用
标签: php html phpmyadmin