Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 16th, 2006, 6:15 PM   #1
KyrinComaBlack
Programmer
 
KyrinComaBlack's Avatar
 
Join Date: Dec 2005
Location: Toronto, Ontario, Canada
Posts: 48
Rep Power: 0 KyrinComaBlack is on a distinguished road
Send a message via MSN to KyrinComaBlack
Login Problem

ok i have this and it works

[php]
<?php
include("./backend/config.php");

$username = $_POST['username'];
$password = md5($_POST['password']);
$ip = $_SERVER['REMOTRE_ADDR'];

if($_REQUEST['do'] == 0){
if(isset($_POST['submit'])){
session_start();
$q = "SELECT * FROM user WHERE username='$username' AND password='$password' LIMIT 1";
$findmember = mysql_query($q);
$rows = mysql_num_rows($findmember);

if($rows > 0){
setcookie("username", $username, time()+(60*60*24*5), "/", "$ip");
setcookie("password", $password, time()+(60*60*24*5), "/", "$ip");
$_SESSION['username'] = $username;
print(" ".$_COOKIE['username']." You have successfully logged in!");
print("Click <a href=\"user.php?username=".$_SESSION['username']."\">here</a>");
}else{
print("Username or password is invalid. Please try again!");
}
}
}
[/php]

I don't really want to use session but rather use cookies but im having trouble.

like on this code
[php]
print("Click <a href=\"user.php?username=".$_SESSION['username']."\">here</a>");
[/php]

I want to use this
[php]
print("Click <a href=\"user.php?username=".$_COOKIE['username']."\">here</a>");
[/php]

I know that it doesn't set the value to $_COOKIE til the next page or so i heard. But the other thing like. I want to check for the verfication like if that user suppose to be in that area by member level and also if theres a way i don't have to rely on session but rather cookies. I want to force cookies. I forgot what i was going to say next but ill reply when I get it.

if i can use cookies without session how would they be called so i can use them?
KyrinComaBlack is offline   Reply With Quote
Old Feb 16th, 2006, 6:40 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Obviously, a cookie can't be set until you respond to the browser with the page, and it can't be retrieved until the browser contacts you with a new request. It's the nature of the paradigm.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Feb 16th, 2006, 6:45 PM   #3
KyrinComaBlack
Programmer
 
KyrinComaBlack's Avatar
 
Join Date: Dec 2005
Location: Toronto, Ontario, Canada
Posts: 48
Rep Power: 0 KyrinComaBlack is on a distinguished road
Send a message via MSN to KyrinComaBlack
Then how do I retrieve the infomation from the cookie and use that for the script.

And I deleted my cookies after I ran the script and I successfully logged in but when I tried it again it continued to say invalid when I used the same name again?
KyrinComaBlack is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:30 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC