Redirect to URL after LOGIN

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
caitanya
Forum Newbie
Posts: 9
Joined: Mon Jan 19, 2004 3:36 pm
Location: Switzerland

Redirect to URL after LOGIN

Post by caitanya »

Hi

I would like to make something i have no idea of. Since my Host has a Mysql Database and PHP installed i have to do it with PHP & SQL.

I have one PASSWORD Field - if the user enters i.e. CAR than he is redirected to http://www.mywebsite.com/car.htm and if he enters SOUND he is redirected to http://www.mywebsite.com/car_1.htm, ...

I would like to have PASSWORDs and URLs stored in mySql Database and whenever user starts the first file (ie. index.php) it should connect to the database and wait for him to type in the PASS - then it should redirect to the URL that is stored in the database and connected to the Password.

Is this possible? Any hint would be great help.

Thanks
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

Yes create a form with a password field. In the form you will want something like this:

Code: Select all

<form method="post" action="checkpass.php">
Then in the page that the form is pointing to, check if the variable is equal to any number of passwords stored in an array. The array should be set up like this:

Code: Select all

1 => levelonepassword
2 => leveltwopassword
3 => Vncodn1dniZnh
With the level number being the number and the value being the password. Then if the user's password is equal to any of them, just use:

Code: Select all

header (Location: somewhere.php);
to send them there.
Post Reply