![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Feb 2005
Posts: 5
Rep Power: 0
![]() |
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? |
|
|
|
|
|
#2 |
|
Professional Programmer
|
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 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|