Jump to content
Sign in to follow this  
nouaman

php : user profile information display after login

Recommended Posts

Hi ,

 

please be noted that i need help with php fetshing logged user s data and displaying all the data regarding the logged user below is explanation of what happens and the code im using

 

-so i was able to write a code that authenticare registered users , for example when i log with let say a username "steve" i direct user to profile page wich says welcome steve and in the same page i put for test a link that says "see my profile"

 

when i click on that link "see my profile" it shows me "Welcome SELECT * FROM users WHERE username =steve. Click here to"

 

im pretty sur that this has to do with this line of code:

 

Welcome <?php echo "SELECT * FROM users WHERE username =".$_SESSION["username"] ; ?>

 

please refer to code below to locate the line that is giving me the wrong output

 

 

Note : i ve been digging on that in google and im sur that line should give the info of the logged user please help me with this matter and of you need more info let me know

 

thanks in advace

 

 

 

----------------------------------------------------- code-----------------------

 

 

<?php
session_start();
?>
<html>
<head>
<title>User Login</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
<table border="0" cellpadding="10" cellspacing="1" width="500" align="center">
<tr class="tableheader">
<td align="center">User Dashboard</td>
</tr>
<tr class="tablerow">
<td>
<?php
if($_SESSION["username"]) {
?>
Welcome <?php echo "SELECT * FROM users WHERE username =".$_SESSION["username"] ; ?>.
Click here to <a href="logout.php" tite="Logout">Logout.<br /> <a href="profile.php" tite="profile"> see my profile
<?php
}
?>
</td>
</tr>
</body></html>

Share this post


Link to post
Share on other sites

Yeah, you're just telling it to print out a SQL query. If you want to use a database you need to actually connect to the database server, log in, select the database to use, send the query, get the results, etc. There's an article here about how to do it using PDO, the section on prepared statements is what you would use to look up the user.http://www.mysqltutorial.org/php-querying-data-from-mysql-table/

Share this post


Link to post
Share on other sites

use this query for unique

<?php

$query = "SELECT name,email,phone FROM users WHERE email =".$_SESSION["email"] ;

?>

The issue is not the query. The issue is the OP actually needs to interact with the database.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×