Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 16th, 2005, 3:30 PM   #1
jbh5000
Newbie
 
Join Date: Feb 2005
Posts: 5
Rep Power: 0 jbh5000 is on a distinguished road
PHP Question

Ok, here is my situation. I am very new to PHP & MYSQL. Prior to learning this I was only experienced with HTML so I am pretty green and I have a couple of questions:

1. I am developing a site where I will have about 10 pages which will only be for members who have registered for my website. Here is my question. I plan to use PHP/MYSQL to verify that the user name matches password etc.. in the MYSQL database to allow access to these pages. My problem is that I don't know how to keep someone logged in without them having to log in each time they switch pages. Should I only have links to the proteced pages through 1 protected page. Then the user could just log in and go to a members page which would have links to the protected page? The downside is if they click on an unprotected page then try to go back to a protected page they will have to re-login. Or is there a better way?

2. Also could I set up a PHP script for links to pages, then if they change I can just update the script instead of updating every link in the site? I think I know how to do this. Is this a good idea?

3. Last is there a way to carry data output from a PHP script to the next page? Example. I have a login page that asks for e-mail and password. I query mySQL database to verify that they match. I then want to open a "member" page which will have about 5 places where I need to insert data from this members database. So assuming the password is correct the new page opens and there is a table data cell where I want the user's name from the database to appear there as text. My problem is that after I run the php script on the login page it directs me to a new page. This new page does not know who this user is, as it is a master page with places that need info from the mysql database. Is there a way to carry over output from the login page so that the php script would have something to compare to and locate desired data? Or would the user need to enter their data again on this page?
jbh5000 is offline   Reply With Quote
Old Feb 16th, 2005, 4:17 PM   #2
Dizzutch
Professional Programmer
 
Dizzutch's Avatar
 
Join Date: Dec 2004
Location: Worcester, MA
Posts: 441
Rep Power: 4 Dizzutch is on a distinguished road
Send a message via ICQ to Dizzutch Send a message via AIM to Dizzutch Send a message via MSN to Dizzutch Send a message via Yahoo to Dizzutch
alright, i unfortuantely don't have time to explain all of them in detail, but i'll help you on your way and google/php.net will be able to give you details.
1) you can set a cookie and or use the $_SESSION variable in PHP to store the username that logged in, and if the cookie or $_SESSION variable is set on the next page, skip the logon procedure.
2) Templates are always a good idea..
3) you can use the $_POST and $_GET variables. $_GET variables sit behind the page name ex. http://www.domain.com/index.php?user...o&password=bar
(ps. don't pass passwords that way, ever!). you can now access the username and password variables by doing $username = $GET['username']; $password = $_GET['password']. Another option is to use the global keyword in conjunction with variables. look at the php.net documentation for more info on this ways

good luck
Dizz
__________________
naked pictures of you | PFO F@H stats
Dizzutch is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:12 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC