| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 45265 | 2004-05-16 09:30:00 | php session variables | bliss (4037) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 236962 | 2004-05-16 09:30:00 | hello all , I have a problem with session variables . The code attached is for the login screen which posts back to it self to query the database and perform the login sequence. I have commented the code to explain what's going on . the problem is I don't seem to be able to start the session and make the variable accessible on other pages. can you please help me with this problem <? //session_start(); header("Chache-control : private"); if (session_is_registered("staff_id")) //if 1 { echo $_SESSION["staff_id"]; header("Location: ../mainindex.php"); // redirect logedin user } else // else 1 { if (isset($HTTP_POST_VARS['submit'])) // if 2 { include('connect.php'); $u_name = $HTTP_POST_VARS['u_name']; //retrives posted user name and password $p_word = $HTTP_POST_VARS['p_word']; $query = "select * from staff"; // query $result = mysql_query($query); $num_results = mysql_num_rows($result); for ($i=0; $i<$num_results; $i++) { $row = mysql_fetch_array($result); $staff_id = ($row['staff_id']); $staff_name=($row['staff_name']); $staff_password=($row['staff_password']); if ($u_name == $staff_name) // testing the input { if ($p_word == $staff_password) { session_start(); //start of session session_register($staff_id); // session registeration $_SESSION["staff_id"] = $staff_id; Header('Location: ../php_scripts/mainindex.php'); // redirection of successfull login exit(); } } if (($i+1) == $num_results) // tests to see if at end of db { Header('Location: sec2.php'); // redirects unsuccesfull login. exit(); } } } else // else 2 { ?> (..:::html code from here) |
bliss (4037) | ||
| 236963 | 2004-05-16 09:53:00 | If you dont get any replys/help to this thread try posting this question here: http://www.webdeveloper.co.nz/ Good luck :) |
stu120404 (268) | ||
| 236964 | 2004-05-16 10:02:00 | sweet | bliss (4037) | ||
| 1 | |||||