流程是这样的,登录(login.php)->更改密码(changepass.php),每个用户都必须更改密码->重定向到主页(homepage.php),用户可以在其中查看他/她的帐户详细信息。 ...我在主页上想要的是,根据用户的信息或学生ID及其全名向用户致意,但只有我可以显示用户的学生ID,因为我回显会话。这是我的 homepage.php 代码
<?php session_start(); ?>
<?php require('connect/connect.php'); ?>
<!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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home Page</title>
<link href="mm_spa.css" rel="stylesheet" type="text/css" />
</head>
<body class="oneColElsCtrHdr">
<td width="487" valign="top">
<?php
// this is the session id where i could only get from the user(student id)
echo $_SESSION['username'];
$voter = $_SESSION['username'];
function getuserinfo($info){
$info_select = mysql_query ("SELECT `$info` FROM new_reg_student WHERE studid='$voter'");
//this is my line 116 which i got an error saying
//Warning: mysql_query() expects parameter 1 to be string,
//resource given in C:\xampp\htdocs\project\homepage.php on line 116
if ($query_get = mysql_query($info_select)) {
if ($result = mysql_result($query_get, 0, $info)) {
return $result;
}
}
}
$fname = getuserinfo('fname');
$lname = getuserinfo('lname');
echo 'hello '. $fname .' '.$lname.'';
?>
</td>
<div id="footer">
<p>Footer</p>
<!-- end #footer --></div>
<!-- end #container --></div>
</body>
</html>
这是我的 homepage.php 的预览