rainprop Posted March 10, 2010 Share Posted March 10, 2010 b4 this i had a problem where the query failed..and its solved now..but now it directs me to a different page.. (login-failed.php) where from what i see, it should direct me to (member-index.php) tis is the code.. $qry="SELECT * FROM `user` WHERE user_id='login' AND user_password='".md5($_POST['password'])."'"; $result=mysql_query($qry); if($result) { if(mysql_num_rows($result) == 1) { session_regenerate_id(); $member = mysql_fetch_assoc($result); $_SESSION['SESS_USER_ID'] = $member['user_id']; $_SESSION['SESS_EMP_NAME'] = $member['emp_name']; session_write_close(); header("location: member-index.php"); exit(); }else { header("location: login-failed.php"); exit(); } }else { die("Query failed"); } is the mistake here?? $_SESSION['SESS_USER_ID'] = $member['user_id']; $_SESSION['SESS_EMP_NAME'] = $member['emp_name']; can someone tell me what is this code for?? thanks. Link to comment https://forums.phpfreaks.com/topic/194744-directs-to-a-different-page/ Share on other sites More sharing options...
trq Posted March 10, 2010 Share Posted March 10, 2010 Your query is either returning more than or less then 1 result. Link to comment https://forums.phpfreaks.com/topic/194744-directs-to-a-different-page/#findComment-1024106 Share on other sites More sharing options...
rainprop Posted March 10, 2010 Author Share Posted March 10, 2010 more or less than 1 result?? hows that possible...i don get it.. right now in table user,i have user_id, user_password,emp_num, and emp_name. where emp_num is the primary key in the employee table. so is the table wrong?? thanks. Link to comment https://forums.phpfreaks.com/topic/194744-directs-to-a-different-page/#findComment-1024109 Share on other sites More sharing options...
teamatomic Posted March 10, 2010 Share Posted March 10, 2010 Does the form widget name= have a value of login? if so then: $login= $_POST['login'] and then: WHERE user_id='$login' is the mistake here?? $_SESSION['SESS_USER_ID'] = $member['user_id']; $_SESSION['SESS_EMP_NAME'] = $member['emp_name']; can someone tell me what is this code for?? The above code takes elements of an array named $member, obtained from querying the DB and assigns the values to similar session vars. As for the error or problem. Have you tried echo'ing out the results you get from the form and the DB to see if its what you expect? or dont expect? Now here is the big question, if you cant answer it things are really broke. Why are you using session_regenerate_id() and session_write_close() HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/194744-directs-to-a-different-page/#findComment-1024112 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.