Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 01-08-2006, 04:54 PM Problem Verify Login
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
Okay i am trying to create an new script from scratch and im working on the login system, and i am having problems with it writing the id & md5pass to the cookie files to be called upon later to verify that the user is logged in,

here is the current user login process script

PHP Code:
$usr $_POST['usr'];
$pwd $_POST['pwd'];
$admin $_POST['admin'];

$md5pass md5($pwd);

$res "SELECT * FROM contact WHERE username='$usr' && password='$md5pass'";
$subres mysql_query($res) or die(mysql_error());
if(
mysql_num_rows($res) > ){
echo 
"Incorrect username & Password";
header("Location: ../../index.php?p=login");
}
else{
$id $subres['id'];
$pwda $subres['password'];
setcookie("id",$id,time()+60*60*24*365);
setcookie("password",$pwda,time()+60*60*24*365);
}

if(!
$subres['group'] == 6){
header("Location: ../../index.php?p=loggedin ");
}
else{
header("Location: ../../admin/index.php ");

im lost now
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
 
Register now for full access!
Old 01-09-2006, 12:49 AM
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
Just curious but why not uses sessions to pass the info from page to page?

Also if you're going to create your own cookie wouldn't the id be enough. I assume you won't be asking visitors to continue logging in on each page so is there a reason why you would need to check their password again later?

I can see storing the username, but not sure why the password.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 01-09-2006, 06:54 AM
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
i tried session but it did not work well, but i can try agian. nothing is transferd and im not a 100% about how to use sessions.
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Old 01-09-2006, 07:42 PM
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
still no go,

the info is not getting from page to page
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Old 01-09-2006, 08:01 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
How do you currently read back the cookie details? Can we see the other page to which this info has to get to?

Sessions are simple enough - you need to call session_start() on every page you want to have sessions enabled, making sure to do this before any html output as it involves changing headers (the same as setting cookies, which is how sessions usually work internally). Then you can get and set items in the $_SESSION array, and rertrieve them on any page on which you have called session_start(). When you want to log someone out call session_start() again to call up the right session info and then session_destroy() to end it.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 01-11-2006, 10:20 PM
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
eh i finally got it to work using cookies, took me and a friend about 5-6 hrs of debugging it till it got the info that was correct
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Reply     « Reply to Problem Verify Login
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.24021 seconds with 12 queries