[英]How do I get a specific user outputting their name once they logged in
Ok, I will elaborate but keep it simple. 好的,我会详细说明,但保持简单。 1. Once User Registers, their information is stored into a database (already Completed) 2. Once User goes to login and successfully gets authorization to visit homepage.
1.一旦用户注册,他们的信息就会存储到数据库中(已经完成)。2.一旦用户登录并成功获得访问首页的授权。 How do I output their first and last name.
如何输出他们的名字和姓氏。
I know this is php, but I am using PDO and php. 我知道这是php,但是我正在使用PDO和php。 Hopefully my code can help you help me.
希望我的代码可以帮助您。 Thanks
谢谢
//INSERT THE INFORMATION INTO THE DATABASE
$query = "INSERT INTO stable (email, first_name, last_name, user_name, user_pass, re_password ) VALUES (:useremail, :firstname, :lastname, :username, :password, :repassword)";
$result = $linkID->prepare($query);
$result->execute(array(
':useremail' => $useremail,
':firstname' => $firstname,
':lastname' => $lastname,
':username' => $username,
':password' => $password,
':repassword' => $repassword
));
//Displays an appropriate message
if ($result) {
// logged in
header('Location: ../inc/home.php');
};
Html: HTML:
<div id="div2" class="container">
<div class="jumbotron text-center" style=" background-color:transparent ; position:relative; bottom:145px;">
<p><?php <!--Can you please help me output name here--> ?></p>
</div>
</div>
provided you are authorizing the user and session ID, and storing your variables correctly you can display their name with 如果您正在授权用户和会话ID,并且正确存储了变量,则可以使用
<?php echo "Hello $firstname $lastname!";
edit You may want to wrap the above code in its own variable, that way you can do: 编辑您可能希望将上面的代码包装在自己的变量中,这样您可以:
if ($result) {
// logged in
header('Location: ../inc/home.php');
$variablename = "Hello $firstname $lastname!"
};
<div id="div2" class="container">
<div class="jumbotron text-center" style=" background-color:transparent ; position:relative; bottom:145px;">
<p><?php echo "$variablename" ?></p>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.