用户个人资料未显示其数据

时间:2013-11-23 13:49:55

标签: mysql profile

我想创建一个用户详细信息页面,我已创建此代码检查此代码及其错误,请告诉我应该做些什么来使它正确,如果你给我任何代码添加到我的代码然后亲切告诉我我把代码放在哪里。

它给了我以下错误

Notice: Undefined index: id in C:\xampp\htdocs\mysql_login\user_details.php on line 32

Notice: Undefined index: username in C:\xampp\htdocs\mysql_login\user_details.php on line 33

Notice: Undefined index: password in C:\xampp\htdocs\mysql_login\user_details.php on line 34

Notice: Undefined index: name in C:\xampp\htdocs\mysql_login\user_details.php on line 35

Notice: Undefined index: address in C:\xampp\htdocs\mysql_login\user_details.php on line 36

Notice: Undefined index: id in C:\xampp\htdocs\mysql_login\user_details.php on line 32

Notice: Undefined index: username in C:\xampp\htdocs\mysql_login\user_details.php on line 33

Notice: Undefined index: password in C:\xampp\htdocs\mysql_login\user_details.php on line 34

Notice: Undefined index: name in C:\xampp\htdocs\mysql_login\user_details.php on line 35

Notice: Undefined index: address in C:\xampp\htdocs\mysql_login\user_details.php on line 36
View All Details
ID  Username    Password    Name    Address


Notice: Undefined index: id in C:\xampp\htdocs\mysql_login\user_details.php on line 32

Notice: Undefined index: username in C:\xampp\htdocs\mysql_login\user_details.php on line 33

Notice: Undefined index: password in C:\xampp\htdocs\mysql_login\user_details.php on line 34

Notice: Undefined index: name in C:\xampp\htdocs\mysql_login\user_details.php on line 35

Notice: Undefined index: address in C:\xampp\htdocs\mysql_login\user_details.php on line 36
View All Details
ID  Username    Password    Name    Address


Notice: Undefined index: id in C:\xampp\htdocs\mysql_login\user_details.php on line 32

Notice: Undefined index: username in C:\xampp\htdocs\mysql_login\user_details.php on line 33

Notice: Undefined index: password in C:\xampp\htdocs\mysql_login\user_details.php on line 34

Notice: Undefined index: name in C:\xampp\htdocs\mysql_login\user_details.php on line 35

Notice: Undefined index: address in C:\xampp\htdocs\mysql_login\user_details.php on line 36
View All Details
ID  Username    Password    Name    Address


Notice: Undefined index: id in C:\xampp\htdocs\mysql_login\user_details.php on line 32

Notice: Undefined index: username in C:\xampp\htdocs\mysql_login\user_details.php on line 33

Notice: Undefined index: password in C:\xampp\htdocs\mysql_login\user_details.php on line 34

Notice: Undefined index: name in C:\xampp\htdocs\mysql_login\user_details.php on line 35

Notice: Undefined index: address in C:\xampp\htdocs\mysql_login\user_details.php on line 36
View All Details
ID  Username    Password    Name    Address


Notice: Undefined index: id in C:\xampp\htdocs\mysql_login\user_details.php on line 32

Notice: Undefined index: username in C:\xampp\htdocs\mysql_login\user_details.php on line 33

Notice: Undefined index: password in C:\xampp\htdocs\mysql_login\user_details.php on line 34

Notice: Undefined index: name in C:\xampp\htdocs\mysql_login\user_details.php on line 35

Notice: Undefined index: address in C:\xampp\htdocs\mysql_login\user_details.php on line 36
View All Details
ID  Username    Password    Name    Address


Notice: Undefined index: id in C:\xampp\htdocs\mysql_login\user_details.php on line 32

Notice: Undefined index: username in C:\xampp\htdocs\mysql_login\user_details.php on line 33

Notice: Undefined index: password in C:\xampp\htdocs\mysql_login\user_details.php on line 34

Notice: Undefined index: name in C:\xampp\htdocs\mysql_login\user_details.php on line 35

Notice: Undefined index: address in C:\xampp\htdocs\mysql_login\user_details.php on line 36
View All Details
ID  Username    Password    Name    Address


Notice: Undefined index: id in C:\xampp\htdocs\mysql_login\user_details.php on line 32

Notice: Undefined index: username in C:\xampp\htdocs\mysql_login\user_details.php on line 33

Notice: Undefined index: password in C:\xampp\htdocs\mysql_login\user_details.php on line 34

Notice: Undefined index: name in C:\xampp\htdocs\mysql_login\user_details.php on line 35

Notice: Undefined index: address in C:\xampp\htdocs\mysql_login\user_details.php on line 36
View All Details
ID  Username    Password    Name    Address


Notice: Undefined index: id in C:\xampp\htdocs\mysql_login\user_details.php on line 32

Notice: Undefined index: username in C:\xampp\htdocs\mysql_login\user_details.php on line 33

Notice: Undefined index: password in C:\xampp\htdocs\mysql_login\user_details.php on line 34

Notice: Undefined index: name in C:\xampp\htdocs\mysql_login\user_details.php on line 35

Notice: Undefined index: address in C:\xampp\htdocs\mysql_login\user_details.php on line 36
View All Details
ID  Username    Password    Name    Address


Notice: Undefined index: id in C:\xampp\htdocs\mysql_login\user_details.php on line 32

Notice: Undefined index: username in C:\xampp\htdocs\mysql_login\user_details.php on line 33

Notice: Undefined index: password in C:\xampp\htdocs\mysql_login\user_details.php on line 34

Notice: Undefined index: name in C:\xampp\htdocs\mysql_login\user_details.php on line 35

Notice: Undefined index: address in C:\xampp\htdocs\mysql_login\user_details.php on line 36
View All Details
ID  Username    Password    Name    Address


Notice: Undefined index: id in C:\xampp\htdocs\mysql_login\user_details.php on line 32

Notice: Undefined index: username in C:\xampp\htdocs\mysql_login\user_details.php on line 33

Notice: Undefined index: password in C:\xampp\htdocs\mysql_login\user_details.php on line 34

Notice: Undefined index: name in C:\xampp\htdocs\mysql_login\user_details.php on line 35

Notice: Undefined index: address in C:\xampp\htdocs\mysql_login\user_details.php on line 36
View All Details
ID  Username    Password    Name    Address


Notice: Undefined index: id in C:\xampp\htdocs\mysql_login\user_details.php on line 32

Notice: Undefined index: username in C:\xampp\htdocs\mysql_login\user_details.php on line 33

Notice: Undefined index: password in C:\xampp\htdocs\mysql_login\user_details.php on line 34

Notice: Undefined index: name in C:\xampp\htdocs\mysql_login\user_details.php on line 35

Notice: Undefined index: address in C:\xampp\htdocs\mysql_login\user_details.php on line 36
View All Details
ID  Username    Password    Name    Address


Notice: Undefined index: id in C:\xampp\htdocs\mysql_login\user_details.php on line 32

Notice: Undefined index: username in C:\xampp\htdocs\mysql_login\user_details.php on line 33

Notice: Undefined index: password in C:\xampp\htdocs\mysql_login\user_details.php on line 34

Notice: Undefined index: name in C:\xampp\htdocs\mysql_login\user_details.php on line 35

Notice: Undefined index: address in C:\xampp\htdocs\mysql_login\user_details.php on line 36
View All Details
ID  Username    Password    Name    Address


Notice: Undefined index: id in C:\xampp\htdocs\mysql_login\user_details.php on line 32

Notice: Undefined index: username in C:\xampp\htdocs\mysql_login\user_details.php on line 33

Notice: Undefined index: password in C:\xampp\htdocs\mysql_login\user_details.php on line 34

Notice: Undefined index: name in C:\xampp\htdocs\mysql_login\user_details.php on line 35

Notice: Undefined index: address in C:\xampp\htdocs\mysql_login\user_details.php on line 36
View All Details
ID  Username    Password    Name    Address


Notice: Undefined index: id in C:\xampp\htdocs\mysql_login\user_details.php on line 32

Notice: Undefined index: username in C:\xampp\htdocs\mysql_login\user_details.php on line 33

Notice: Undefined index: password in C:\xampp\htdocs\mysql_login\user_details.php on line 34

Notice: Undefined index: name in C:\xampp\htdocs\mysql_login\user_details.php on line 35

Notice: Undefined index: address in C:\xampp\htdocs\mysql_login\user_details.php on line 36
View All Details
ID  Username    Password    Name    Address


Notice: Undefined index: id in C:\xampp\htdocs\mysql_login\user_details.php on line 32

Notice: Undefined index: username in C:\xampp\htdocs\mysql_login\user_details.php on line 33

Notice: Undefined index: password in C:\xampp\htdocs\mysql_login\user_details.php on line 34

Notice: Undefined index: name in C:\xampp\htdocs\mysql_login\user_details.php on line 35

Notice: Undefined index: address in C:\xampp\htdocs\mysql_login\user_details.php on line 36
View All Details
ID  Username    Password    Name    Address

View All Details
ID  Username    Password    Name    Address

以下是我的代码:

 <?php
    if(!isset($_COOKIE['loggedin'])){
        header("location:index.php");
    }

session_start();

if(!isset($_SESSION['user'])){

header("location: index.php");
}
else {

?>


<?php
$username = "root";
    $password = "123";
    $hostname = "localhost";

    $dbhandle = mysql_connect($hostname, $username, $password) or die("Could not connect to database");

    $selected = mysql_select_db("login", $dbhandle);

$query = "select * from users";

$run = (mysql_query($query) or die(mysql_error));

while($row=mysql_fetch_assoc($run)){

    $id = $row['id'];
    $username = $row['username'];
    $password = $row['password'];
    $name = $row['name'];
    $address = $row['address']; 
?>
<html>
    <head>
        <title>Details</title>
    </head>

<body>
<table width="1000" border="2" align="center" bgcolor="pink"> 
    <tr>
        <td colspan="10" align="center" bgcolor="yellow"><h1>View All Details</h1></td>
    </tr>

    <tr bgcolor="orange">
        <th>ID</th>
        <th>Username</th>
        <th>Password</th>
        <th>Name</th>
        <th>Address</th>
    </tr>
<tr align="center">
        <td><?php echo $id; ?></td>
        <td><?php echo $username; ?></td>
        <td><?php echo $password; ?></td>
        <td><?php echo $name; ?></td>
        <td><?php echo $address; ?></td>


    </tr>
<?php } ?>


</table>


</body>
</html>

<?php } ?>

2 个答案:

答案 0 :(得分:0)

知道了,你还没有连接到我想要的数据库。 它应该是

 $run = mysql_query($selected,$query);

试试这个应该可行,因为我今天刚刚制作了一个个人资料页面。

希望有所帮助

POOM

答案 1 :(得分:0)

首先,这不是它注意到的错误,它是在你使用WAMP软件时产生的。 或者只是定义变量

$id = '';
$username ='';
$password = '';
$name = '';
$address=''; 
before while loop 

或关闭通知;希望它会对你有所帮助。 :)