Jump to content

Recommended Posts

Hi.  I am very new to all of php, mysql and the program dreamweaver.  I am teaching how to use all of this at the same time! Now, I have created a website with a login page and all the relevant forms to create an account.  It all works perfectly.  Now i am having trouble understanding the next bit.  Heres what i want;

 

I would like the next page after you log in to display all of your personal details and ONLY your personal details.  Can someone tell me how to do this or where i can learn it.  Sorry if that explaination is not good enough.  If someone can help i am willing to go into more detail on my database and webpage.  Thank you

Link to comment
https://forums.phpfreaks.com/topic/112680-members-login-help/
Share on other sites

You would simply create a profile.php script which queries the database based on a users id stored within the $_SESSION array upon login. eg;

 

session_start();

if (isset($_SESSION['userid'])) {

  $sql = "SELECT name,data FROM users WHERE id = '{$_SESSION['userid']}'";

  // execute query and display the page.

} else {

  // user not logged in.

}

Link to comment
https://forums.phpfreaks.com/topic/112680-members-login-help/#findComment-578676
Share on other sites

Sessions are a bit more secure, DarkWater, because you can change a $_GET variable in the URL and there is nothing to check against so that the user can only see their profile.

 

Having a session can (somewhat) ensure that they can only see their own information.

Link to comment
https://forums.phpfreaks.com/topic/112680-members-login-help/#findComment-578683
Share on other sites

@JD*: Yeah, for only viewing your own information sessions would be better, but I figured he wants a true "profile" page where you can view only one person's info at a time and he worded it incorrectly.  In that case GET would be better. ;D

 

Ah, I see what you're saying. I think he's looking for the former, though, like on this board where you can only see your own profile (and probably edit it), but you're correct, $_GET would be better used to only see one profile at a time for others.

Link to comment
https://forums.phpfreaks.com/topic/112680-members-login-help/#findComment-578688
Share on other sites

To make like a real session where the info will carry you'll prolly need to first get the data from POST or GET variables http://us2.php.net/manual/en/reserved.variables.post.php.

Then you want to check that against a MySQL database and save it into session variables (if it matches the DB), and then make a script to check it like thorpe was saying.

 

Check out the variables listed on the top left side of the page above, especially in your case $_POST, $_GET and $_SESSION.

Remember also that you have to use a session_start() call at the TOP (or at least before output I think) of any page that you want to use sessions on.

 

Here's some tutorials on this stuff..

http://www.w3schools.com/PHP/php_mysql_intro.asp -- MySQL Query Syntax Examples

http://www.tizag.com/phpT/phpsessions.php -- PHP Sessions

http://phpeasystep.com/phptu/6.html -- Login Page Example

http://us.php.net/security.database.sql-injection -- About Security..

http://us2.php.net/mysql_real_escape_string -- More to do with security..

 

And remember to check out http://php.net...

You can lookup any function you want and see how it works, the functions you'll need to use in conjunction with it AND examples- really neat stuff...

 

Anyways HTH

 

Link to comment
https://forums.phpfreaks.com/topic/112680-members-login-help/#findComment-578690
Share on other sites

hey everyone.  Thank you for all your help.  Yes you are right.  I would like a page that displays many details of the particular person that logs in.  I will go through all your comments very carefully and study what i need to know.  Thank you all for all your help.  Im sure you will all be hearing from me again very soon! lol.

 

fife

Link to comment
https://forums.phpfreaks.com/topic/112680-members-login-help/#findComment-579931
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.