如何在个人资料页面中回显我的用户信息 [英] How to echo my users information in a profile page

查看:174
本文介绍了如何在个人资料页面中回显我的用户信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个用户个人资料页面,而我想要做的是如何在用户从登录页面登录后如何从数据库中回显用户信息,以便在个人资料页面中显示,但问题是该回显用户ID未定义.ilease我需要帮助,任何人都可以帮助我修复我的代码,这是php和sql的新功能.

我尝试过的事情:

profile.php

i am trying to create a user profile page,and what i want right is how to echo the users information from the database to display in a profile page once they login from the login page,but the problem is that will echo The user ID is not defined.ilease i need help anyone can help me fix my code am new to php and sql.

What I have tried:

profile.php

<?php
include('db.php');
?>
<!DOCTYPE html">
<html>
    <head>
        <title>Profile of an user</title>
    </head>
    <body>

        <div class="content">
<?php
//We check if the users ID is defined
if(isset($_GET['id']))
{
        $id = intval($_GET['id']);
        //We check if the user exists
        $sql = mysql_query('SELECT fst, las, uid, pass,sts,ocp FROM users WHERE id="'.$id.'"');
        if(mysql_num_rows($sql)>0)
        {
                $res = mysql_fetch_array($sql);
                //We display the user datas
?>
This is the profile of "<?php echo htmlentities($res['fst']); ?>" :
<table style="width:500px;">
        <tr>

        <td class="left"><h1><?php echo htmlentities($res['fst']); ?></h1>
        Email: <?php echo htmlentities($dnn['las']); ?><br />
        This user joined the website on <?php echo htmlentities($res['uid']); ?></td>
    </tr>
</table>
<?php
        }
        else
        {
                echo 'This user dont exists.';
        }
}
else
{
        echo 'The user ID is not defined.';
}
?>
                </div>
                 </body>
</html>



login.php



login.php

<?php
include 'db.php';

$uid = $_POST['uid'];
$pass = $_POST['pass'];



$sql = "SELECT * FROM users WHERE uid='$uid' AND pass='$pass'";
$result = mysqli_query($conn,$sql);

if($row = mysqli_fetch_assoc($result)){
   header("Location: profile.php");
   
}else{
     echo "invalid username or password";
}
?>

推荐答案

_GET [ ' id'])) {
_GET['id'])) {


id = intval(
id = intval(


_GET [ id']); // 我们检查用户是否存在
_GET['id']); //We check if the user exists


这篇关于如何在个人资料页面中回显我的用户信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆