Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 04-25-2004, 08:26 PM   #1 (permalink)
ADZ
 
Master Techie

Join Date: May 2003

Posts: 2,233

ADZ is on a distinguished road

Send a message via Yahoo to ADZ
Default Simple PHP Login

I am looking for a very simple PHP script that looks for a username and password and then goes to a page.

A little twist to it tho, I want different usernames and passwords and the logins to go to different sites...

Eg:

U: Bob
P: bob
-> Goes to bob.php

U: Cedrick
P: cedrick
-> Goes to cedrick.php

Any help would be greatly appreciated!!!!
ADZ is offline  
Old 04-25-2004, 08:49 PM   #2 (permalink)
 
Super Techie

Join Date: Apr 2004

Posts: 316

BlazingWolf

Default

You could do this several different ways. It really depends on how many users you have. Are you going to have like 5-10 users or much more than that?
__________________
BlazingWolf
<font color=\'red\'>
<b>
<a href=\'http://www.gaming-forums.org\'>
Gaming-Forums.org
<a/>
</b>
</font>
BlazingWolf is offline  
Old 04-25-2004, 11:58 PM   #3 (permalink)
ADZ
 
Master Techie

Join Date: May 2003

Posts: 2,233

ADZ is on a distinguished road

Send a message via Yahoo to ADZ
Default

probably 5-10 users. I do not know MySQL and my servers probably dont support it. I barely know PHP...
ADZ is offline  
Old 04-26-2004, 12:00 AM   #4 (permalink)
 
Monster Techie

Join Date: Jul 2003

Posts: 1,179

Emily is on a distinguished road

Send a message via AIM to Emily
Default

And do you want people to be able to register and create new usernames, or is there a predefined set of usernames and where they should go?

If you want people to be able to register, you're going to need to use SQL or write the account information to a file.

If you just have a few predefined usernames/passwords and where they should, case you can use a switch statement. I'm too lazy to get the syntax right now, but if this is the kind of thing you want I'll write it out for you.
__________________
<a href=\"http://www.upstark.com\">www.upstark.com</a>
Emily is offline  
Old 04-26-2004, 12:04 AM   #5 (permalink)
ADZ
 
Master Techie

Join Date: May 2003

Posts: 2,233

ADZ is on a distinguished road

Send a message via Yahoo to ADZ
Default

yeah i dont want people to register, just a cpl of predefined users. Any help would be muchly appreciated
ADZ is offline  
Old 04-26-2004, 12:36 AM   #6 (permalink)
 
Monster Techie

Join Date: Jul 2003

Posts: 1,179

Emily is on a distinguished road

Send a message via AIM to Emily
Default

Ok, try this (omit the spaces from the tags, obviously, and this is all assuming that the text field for the username is called "username" and the text field for the password is called "password"):

< ?php
switch($username) {
case "Bob":
if ($password == "bob") {
include("bob.php");
} else {
print "Bad password."
}
break;

case "Cedrick":
if ($password == "cedrick") {
include("cedrick.php");
} else {
print "Bad password."
}
break;
}
? >

If the include statement doesn't work for you, you can use this instead:

header("Location: http://www.yoursite.com/bob.php");

If you do use header() instead of include(), you have to put the PHP code at the very, very top of the page, even above the < html> tag.

Hope this works. If it doesn't, let me know.
__________________
<a href=\"http://www.upstark.com\">www.upstark.com</a>
Emily is offline  
Old 04-26-2004, 10:40 AM   #7 (permalink)
ADZ
 
Master Techie

Join Date: May 2003

Posts: 2,233

ADZ is on a distinguished road

Send a message via Yahoo to ADZ
Default

Thank YOu Muchly. I will giv er' a shot!

Thanks!!!
ADZ is offline  
Old 04-26-2004, 04:51 PM   #8 (permalink)
 
Super Techie

Join Date: Apr 2004

Posts: 316

BlazingWolf

Default

You sure there is a : after the the case?
__________________
BlazingWolf
<font color=\'red\'>
<b>
<a href=\'http://www.gaming-forums.org\'>
Gaming-Forums.org
<a/>
</b>
</font>
BlazingWolf is offline  
Old 04-26-2004, 06:31 PM   #9 (permalink)
 
Monster Techie

Join Date: Jul 2003

Posts: 1,179

Emily is on a distinguished road

Send a message via AIM to Emily
Default

Yeah, there's definitely a colon after each case, but I just realized that I forgot the semi-colons after the 2 lines that print "Bad Password." I've been doing too much VB lately.
__________________
<a href=\"http://www.upstark.com\">www.upstark.com</a>
Emily is offline  
Old 04-26-2004, 06:37 PM   #10 (permalink)
 
Super Techie

Join Date: Apr 2004

Posts: 316

BlazingWolf

Default

Yeha, thats the only thing about now multiple langauges.
__________________
BlazingWolf
<font color=\'red\'>
<b>
<a href=\'http://www.gaming-forums.org\'>
Gaming-Forums.org
<a/>
</b>
</font>
BlazingWolf is offline  
 
Closed Thread

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
Trackbacks are On
Pingbacks are On
Refbacks are On