eaglelegend Posted May 25, 2008 Share Posted May 25, 2008 Why does "lastlogindate" display as "thislogin"? and nothing shows on "this login"?... on the database and also, why dont the ip adress update itself?? <?php include("header.php"); if(isset($_POST['username']) && isset($_POST['password'])) { $username = strip_tags(stripslashes($_POST['username'])); $password = (md5($_POST['password'])); } if($username && $password) { $check = mysql_num_rows(mysql_query("SELECT * FROM `members` WHERE `username`='$username' AND `password`='$password'")); $ip = $_SERVER['REMOTE_ADDR']; if($check == 1) { $_SESSION['ELv2'] = $username; if(session_register('ELv2')){ Header("Location: index.php"); $sql = mysql_query("UPDATE members SET thislogin='$thislogindate' WHERE username='$username' LIMIT 1"); $sql = mysql_query("UPDATE members SET lastlogin='$lastlogindate' WHERE username='$username' LIMIT 1"); $sql = mysql_query("UPDATE members SET $ip ='$_SERVER['REMOTE_ADDR']' WHERE username='$username' LIMIT 1"); } else { print "Cant set cookie"; } } else { print "Sorry, username/password mismatch!"; } } else { ?> <h2>Login</h2><p> <form action="login.php" method="post"> Username<br> <input type="text" name="username" class="text_box" size="20" title="Please enter the Username you registered here with." alt="Please enter the Username you registered here with."><p> Password<br> <input type="password" name="password" class="text_box" size="20" title="Please enter the Password you registered here with." alt="Please enter the Password you registered here with."><p> <input type="hidden" name="ip" value="set"> <input type="submit" class="text_box" value=" Login " title="Click here to log in." alt="Click here to log in."></form> <?php } include("footer.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/107175-php-question/ Share on other sites More sharing options...
eaglelegend Posted May 25, 2008 Author Share Posted May 25, 2008 anyone know? ??? Quote Link to comment https://forums.phpfreaks.com/topic/107175-php-question/#findComment-549535 Share on other sites More sharing options...
BlueSkyIS Posted May 25, 2008 Share Posted May 25, 2008 i'm not sure what your question is. but here are some tips: pull your SQL out of mysql_query() so you can look at it via echo, then check for mysql_query() errors: $sql = "UPDATE members SET thislogin='$thislogindate' WHERE username='$username'"; echo "sql: $sql<BR>"; // make sure the SQL looks like you expect it to. mysql_query($sql) or die(mysql_error()); // if the query fails, stop and display the error Quote Link to comment https://forums.phpfreaks.com/topic/107175-php-question/#findComment-549537 Share on other sites More sharing options...
eaglelegend Posted May 25, 2008 Author Share Posted May 25, 2008 Thank you, my point is that the "IP" address, isnt updating to the database :/ Quote Link to comment https://forums.phpfreaks.com/topic/107175-php-question/#findComment-549557 Share on other sites More sharing options...
.josh Posted May 25, 2008 Share Posted May 25, 2008 $sql = mysql_query("UPDATE members SET ip ='{$_SERVER['REMOTE_ADDR']}' WHERE username='$username' LIMIT 1"); also just fyi all 3 of your queries are updating the same table under the same conditions so you can just use 1 query with all 3 variables. edit: I also assumed that you meant ip not $ip as your column name. Or since you already set $ip to the remote address, you could do "... ip = '$ip' ..." Quote Link to comment https://forums.phpfreaks.com/topic/107175-php-question/#findComment-549562 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.