Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

   

Reply
 
LinkBack Thread Tools Display Modes
Old 10-01-2004, 09:40 AM   #1 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
PHP/MySQL Login Form Help

Hi i have a login form on my website which asks for the users username and password. I need help getting it to check if the user and password match, etc... and then to redirect to there folder which is there username.

the database table I created is called siteusers and has the following fields:-

ID
Username
Password (MD5)

What i need it to do is when a user types in the username and password it checks if the user exists and if the user does exist it will then check there password and redirect to there area on my domain. e.g http://www.domain.co.uk/username.

however i'm cannot seem to do this in PHP any ideas how i can?
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-01-2004, 03:15 PM   #2 (permalink)
Moderator
 
LazyJim's Avatar
 
Join Date: 10-13-03
Location: UK
Posts: 2,821
iTrader: 0 / 0%
Latest Blog:
None

LazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to all
Send a message via MSN to LazyJim
obviously you've tried, so which bit isn't working?
Or post the likely wrong parts of your script and we can try to spot errors?
__________________

-LJ-

My advice is to look at each case individually, with an informed mind and an appropriately balanced and objective viewpoint.

Web Design and Development, Ipswich, UK.
My deviantArt
LazyJim is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-02-2004, 05:55 AM   #3 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
this is what i have:-

Code:
<? //set the cookie on this page and then go to logact.php //echo "username = $username<br>"; $username = @$HTTP_POST_VARS["username"]; $password_temp = @$HTTP_POST_VARS["password"]; $password = md5($password_temp); $intheform = @$HTTP_POST_VARS["intheform"]; IF (($username == "") AND ($password == "") AND ($intheform == "yes")): $error = "Please enter your username & password"; ELSE: // echo "came through 1 - contains 1 complete field<br>"; IF (($username != "") && ($password != "")): // echo "came through 2 - both fields complete<br>"; require "_inc/connect.php"; $query = "SELECT username, password FROM users WHERE username='$username'"; $result = @MYSQL_QUERY($query) OR DIE ("Failed to $query on line 5"); $num = MYSQL_NUMROWS($result); IF ($num > 0): // echo "came through 3 - found a user<br>"; $sqlpassword = MYSQL_RESULT($result,0,password); IF ($sqlpassword == $password): // echo "came through 4 - user pwd match with db pwd<br>"; setcookie("login",$username,0); echo "<SCRIPT>"; echo "window.location = \"user\"</SCRIPT>"; ELSE: $error = "Incorrect Password. Please try again."; ENDIF; ELSE: $error = "Username does not exist. Please try again."; ENDIF; ELSEIF (($username != "") || ($password != "")): $error = "Please complete the form before submitting."; ENDIF; ENDIF; ?>
All that does it check the username and password but does not forward to the folder associated with that user in the database.

The fields for the database are:-

Username
Password (MD5)
Folder

What i need it to do is once it has checked the username and password i need it to forward to there own folder and prevent access to other peoples folders.
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-02-2004, 07:34 AM   #4 (permalink)
Moderator
 
LazyJim's Avatar
 
Join Date: 10-13-03
Location: UK
Posts: 2,821
iTrader: 0 / 0%
Latest Blog:
None

LazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to all
Send a message via MSN to LazyJim
Ok the forwarding is easy, and as for blocking access to other folders, well you'll have to do check for either what folder they try and use, or create an interface that don't let them see what folder they're using and will only let the right person use the right folder.

Forwarding:
PHP Code:
<?php
$folder_path 
"/whatever/";
header"Location: $folder_path" );
exit;
?>
__________________

-LJ-

My advice is to look at each case individually, with an informed mind and an appropriately balanced and objective viewpoint.

Web Design and Development, Ipswich, UK.
My deviantArt
LazyJim is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
order form requires a login....?! Yousef T. Fahoum Coding Forum 1 01-30-2007 11:54 AM
Form php mysql - problem nster Coding Forum 11 11-13-2006 12:31 PM
Simple PHP / Mysql form !! Kinetic_Mix Coding Forum 1 07-28-2006 02:18 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 02:57 AM.
© Copyright 2008 V7 Inc