brianbayer1 Posted April 22, 2008 Share Posted April 22, 2008 i'm getting a duplicate user_id error here. i wanted to assign a new session id everytime someone logs in. what am i doing wrong? here's the code: <?php $username =$_POST['username']; $password =$_POST['password']; if (strlen($username) <= 25 && strlen($password) <= 25) { mysql_connect('localhost', 'user', 'password'); mysql_select_db('users'); $sql = "SELECT username, password FROM info WHERE username = '$username' AND password = password('$password');"; $result = mysql_query($sql) or die(mysql_error()); $newResult = mysql_fetch_array($result, MYSQL_ASSOC); if ($newResult['password'] = $password) { $_POST['logged'] = true; session_start(); $_SESSION['name'] = session_id(); $session_id = $_SESSION['name']; $_SESSION['username'] = $_POST['username']; $_SESSION['password'] = $_POST['password']; $sql = "UPDATE info SET user_id='$session_id' WHERE username='$username';"; $result2 = mysql_query($sql) or die(mysql_error()); mysql_close(); header("Location: http://localhost/test/members/index.php"); } else { $_POST['not_logged'] = true; header("Location: http://localhost/test/login.php"); } } ?> Link to comment https://forums.phpfreaks.com/topic/102362-duplicate-session-id-problem-phpmysql/ Share on other sites More sharing options...
brianbayer1 Posted April 22, 2008 Author Share Posted April 22, 2008 also, if i close the browser, and then log in under a diff name, it works. so how do i stop having to close the browser? Link to comment https://forums.phpfreaks.com/topic/102362-duplicate-session-id-problem-phpmysql/#findComment-524145 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.