Search
Left Quote    Maybe this world is another planet's Hell.
- Aldous Huxley    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: Remember Me
  This user is offline  gravy
  Subject: "Remember Me" Posted: @ 4:05 pm on Jul 08 2007   

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

Why doesnt my remember me feature work?


Photo Hosting Scripts? It's what I do....
    Viewed: 13,383 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Remember Me" Posted: @ 6:03 pm on Jul 08 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Not sure, it remembers me... Do you have cookies enabled? How's it working for everyone else?




-bs0d | AllSyntax.com

    Viewed: 13,378 Times | Reply to This | To top
  This user is offline  gravy
  Subject: "re: Remember Me" Posted: @ 8:08 pm on Jul 08 2007    

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

no iam talking about in my own script! I can not get it to work....




Photo Hosting Scripts? It's what I do....

    Viewed: 13,371 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Remember Me" Posted: @ 9:12 pm on Jul 08 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Code would help!




-bs0d | AllSyntax.com

    Viewed: 13,364 Times | Reply to This | To top
  This user is offline  gravy
  Subject: "re: Remember Me" Posted: @ 9:01 pm on Jul 09 2007    

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

Oh I am sorry dude...
login.php

Code:


<?
include "header.p hp";
if(isset($_SESS ION['username ']) && isset($_SESSION ['password']) ) {
//REDIRECT TO USERS PROFILE...
header("L ocation: main.php"< img src=http://www. allsyntax.com/f orums/images/sm ilies/wink.gif border=0>;
} //end if logged in

//IF SUBMIT BUTTON PRESSED
if(isset($_POST ['submit'])) {

if(!$_POST['us ername']) die("Erro r: You must enter your username before logging in.";
if(!$_POST['pa ssword']) die("Erro r: You must enter your password before logging in.";


//set cookie if checked
if(!empty($_POS T['stay_in']) ) {
$joined =''.$_POST[' username'].'[ ]'.md5($_POST[ 'password']). '';
setcookie('log in_cookie', $joined, 2147483647, '/', '.main.php');
} //end if

//verify user...
$get_user = mysql_query(&q uot;SELECT * FROM `members` WHERE username = '".$_POS T['username'] ."' AND

user_password = '".md5($ _POST['passwor d'])."' ";
$q = mysql_fetch_obj ect($get_user);
if(!$q) die("< font size='2' face='verdana '><b>L ogin Failure: An error occured, please verify your username and password are correct."< img src=http://www. allsyntax.com/f orums/images/sm ilies/wink.gif border=0>;

//set session variables
$_SESSION['log ged_in'] = 1;
$_SESSION['use rname'] = $_POST['userna me'];
$_SESSION['pas sword'] = $_POST['passwo rd'];
session_write_c lose();

header("L ocation: main.php"< img src=http://www. allsyntax.com/f orums/images/sm ilies/wink.gif border=0>;

} else {
//show login form
?>
<form name="log in" method="p ost" action="& lt;? $_SERVER['PHP_ SELF']; ?>"> ;
<table width="10 0%" align="ce nter" cellpadding=&q uot;3" cellspacing=&q uot;3" border="1 " bgcolor=" <? echo$_CONFIG[' td1']; ?>" bordercolor=&q uot;<? echo$_CONFIG[' border']; ?>" style="bo rder-collapse: collapse" >
<tr>
<tr>
<td align="ce nter" colspan=" 2" bgcolor=" <? echo$_CONFIG[' td1']; ?>"> ;
<font size="2& quot; face="ver dana"> <b>Login to your Account
</td>
</tr>
<td width="25 %,*" align="ri ght" bgcolor=" <? echo$_CONFIG[' td3']; ?>"> ;
<font size="2& quot; face="ver dana"> <b>Userna me:
</td>
<td bgcolor=" <? echo$_CONFIG[' td2']; ?>"> ;
<input type="tex t" id="usern ame" name="use rname"> ;
</td>
</tr>
<tr>
<td align="ri ght" bgcolor=" <? echo$_CONFIG[' td3']; ?>"> ;
<font size="2& quot; face="ver dana"> <b>Passwo rd:
</td>
<td bgcolor=" <? echo$_CONFIG[' td2']; ?>"> ;
<input type="pas sword" id="passw ord" name="pas sword"> ;
</td>
</tr>
<tr>
<td align="ri ght" bgcolor=" <? echo$_CONFIG[' td3']; ?>"> ;
<font size="2& quot; face="ver dana"> <b>Submit :
</td>
<td bgcolor=" <? echo$_CONFIG[' td2']; ?>"> ;
<input type="sub mit" value="Su bmit" name="sub mit" id="submi t"> &nbsp; &nbsp; <font size="1& quot; face="ver dana"> Remember Me? <input type="che ckbox" name="sta y_in[]" checked=" yes">
</td>
</tr>
</table>
</form>
<?
}//end else
include "footer.p hp";
?>


header.php

Code:

<?
ob_start();
session_start() ;
require_once(' connect.php');
require_once(' config.php');

//check cookie
if ($_SESSION['lo gged_in'] != 1 && isset($_COOKIE[ 'login_cookie '])) {
list($user, $pass) = explode('[]', $_COOKIE['logi n_cookie']);
$qu = mysql_query(&q uot;SELECT `user_password` FROM `members` WHERE `username` = '".addsl ashes($user).& quot;'";
if (mysql_num_rows ($qu) == 1) {
$passw = mysql_fetch_obj ect($qu);
if ($passw->use r_password == $pass) {
$_SESSION['log ged_in'] = 1;
$_SESSION['use rname'] = $user;
$_SESSION['pas sword'] = $pass;
}
}
}

if(!isset($_SES SION['username ']) && !isset($_SESSIO N['password'] )) {
$_SESSION['log ged_in'] = 0;
$user = "Guest&q uot;;
$message = "<font size='1' face='verdana '>Welcome <b>$user& lt;/b>. <a href=\"r egister.php\& quot;>[Regis ter]</a> &nbsp; <a href=\"l ogin.php\&quo t;>[Login]&l t;/a>" ;
}else if ($_SESSION['lo gged_in'] == 1 ) {
$user = $_SESSION['use rname'];
$message = "<font size='1' face='verdana '>Welcome <b>$user& lt;/b>, you are now logged in. <a href=\"l ogout.php\&qu ot;>[Logout] </a>&quo t;;
}
?


Any help on this would be awesome!



Edited at 09:03:59 pm on 07/09/07


Photo Hosting Scripts? It's what I do....

    Viewed: 13,336 Times | Reply to This | To top
  This user is offline  WintersDance
  Subject: "re: Remember Me" Posted: @ 3:37 am on Jul 11 2007    

Member #: 353
Rank: User - (27)
Since: 06/19/07
Posts: 36
From: California

Couple of errors I see in the login.php code:

1) Your includes should look like this: include('heade r.php');

2) setcookie('log in_cookie', $joined, 2147483647, '/', '.main.php'); is wrong, it should look like this: setcookie('log in_cookie', $joined, 2147483647, '/', '.www.domain_n ame.com');
* replace www.domain_name .com with your actual domain name and exclude the http:// part.

Hope that helps ya.




wintersdance |     Viewed: 13,319 Times | Reply to This | To top
  This user is offline  misterhaan
  Subject: "re: Remember Me" Posted: @ 2:13 pm on Jul 11 2007    

Member #: 5
Rank: User - (213)
Since: 02/11/05
Posts: 148
From: chair

actually, include "header.p hp"; is perfectly fine. include isn't a function, so if you add the parentheses, you're just doing something like $mystring = ('hello world'); which doesn't really change things.




please note that the above post is likely made up in its entirety.

    Viewed: 13,304 Times | Reply to This | To top
  This user is offline  gravy
  Subject: "re: Remember Me" Posted: @ 3:34 pm on Jul 11 2007    

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

  misterhaan said...

< i> actually, include "header.p hp"; is perfectly fine. include isn't a function, so if you add the parentheses, you're just doing something like $mystring = ('hello world'); which doesn't really change things.

Thanks for the help guys, I will tinker with the address and see if I can get the sucker to work...




Photo Hosting Scripts? It's what I do....

    Viewed: 13,301 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank