I want to create a single profile page for members. The way I want it is
when any user logs in he will automatically be taken to that single
profile page. I am wondering if there is a way I can make the code IN PHP
extract only the profile and passport of that member and display for him
to view. Each loged in member can only view his own profile at that
single page.

ANY ONE THERE PLEASE HELP ME
AS I`M NEW TO PHP.
Thanks.

Recommended Answers

All 10 Replies

You can use session for this purpose. For example, when user login with a valid password and username, register the username under a session and redirect the user to profile page where in the profile page will display the profile of the user that login. This can be done by selecting the profile with condition of the username = to the session register. Session will be destroy when user logout of the page.

You can search on the example in google to guide you. There are many free tutorial and script available. Here is one of the website that can help you:
http://www.trap17.com/index.php/php-simple-login-tutorial_t7887.html

session_start() or something like that and session_destroy()

You are also going to have to use a database to store the users' information ...

Thankx alot!
i created a databases with name,lastname,username,password,email,country and proffesion.
Also created a registration form.
apart from from i also created a Login Form in which only username and password.
Now I need when Someone is logen in To view all of his Datas supplied while registering.
How can i Do this??
Because session helped me only in showing The username and password.
Please reply to this,I need your help.

When the user logs in, check if its a valid login. If, yes, then query the table which has the user details for this username. Since this is a login script, username has to be unique. So, a username can have only 1 row of details.

<?php 
//connection
//get the form variables values
//check for valid login
if (true) {
$query = "select * from table where username='username_value_'";
//get the details
}

The more simple way is to query the table while checking for valid username.

<?php
//connection
//get the form variables
$query = "select * from table where username='username_value' and password='password_value'";
//if mysql returns more than 0 rows display his details. If its an invalid details, display error message or redirect back to login page.

You can check out w3schools for php-mysql tutorial.

Cheers,
Naveen

Thank you so much for your concern,
In your reply from 1 up to 4,I well understand.
But 5 is the most important, Can you please
write down the code which follows to Display someones information after
№4($query) is True.
For example to Display:
name,lastname,username,password,email,country and proffesion.
I`m relying on your Reply.
Thankx.

$query = "select * from table where username='username_value' and password='password_value'";
$result = mysql_query($query);
$row = mysql_fetch_array($result); // if you query returns only 1 row
//while($row = mysql_fetch_array($result){ if your query returns more than 1 row
$firstname=$row['firstname_column'];
$lastname=$row['lastname_column'];
//and so on..

I hope thats clear ?

Thank You so much,
the code helped me in solving the problem
i were experiencing.
Now everything is Okey.

what can i should do with this code that it show me my user profile which is login

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("test", $con);




$result = mysql_query("SELECT * FROM users where id='GET'");
?>

<div class= "nine"><table border="0" cellpadding="1" cellspacing="0" id="tblsubmit" align="center" class="pos6"> 
</div>
<?php
while($row = mysql_fetch_array($result))
  {
  echo "<tr>";


    echo "<td>" . $row['name'] . "</td>";
  echo "<td>" . $row['email'] . "</td>";
   echo "<td>" . $row['password'] . "</td>";
  echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?> 

Hey I've been making a web page and I'm woundering a.) how to get a login/register page(logout too!) and b.) how to get it where when some one creates a new account or logs in to a pre existing one it directs them to a profile page. Lastly I'm woundering how to improve my site.
Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.