mboley370 Posted June 21, 2010 Share Posted June 21, 2010 The script will find the data in my database. If i comment out userSession on the next page that the script below will go to it works fine. However that means there is something wrong with the area below when its assigning variables to my session. I am not sure whats going on, but my sessions aren't working. This is my first test ever on an wamp server using oracle enterprise 11g on a Windows Vista. What am i doing wrong? The code below <?php require_once("includes/userSession.php"); ?> <?php require_once("includes/connection.php"); ?> <?php require_once("includes/functions.php"); ?> <?php if (staffLogged_in()) { redirect_to("staffArea.php"); } $message=""; //check to see if submit button was pressed if (isset($_POST['submit']) || isset($_POST['submit_x'])) { // Form has been submitted. //check to see if fields are not empty if($_POST['email'] =="" || $_POST['password'] ==""){ $message = "Please fill in both fields."; } else { //I used addslashes instead of mySQLprep from function.php since oracle won't support it. //Will probably move to stripslashes then post my variables below that //$email = trim(addslashes($_POST['email'])); $email = ($_POST['email']); $password =($_POST['password']); //$password = trim(addslashes($_POST['password'])); // Check database to see if username and the password exist there. //$query = "SELECT staffMemberID, smFirstName "; //$query .= "FROM staffMember "; //$query .= "WHERE smEmail = '{$email}' "; //$query .= "AND smPassword = '{$password}' "; //$query .= "LIMIT 1"; // Oracle wont support limit 1 $query = "SELECT staffMemberID, smFirstName FROM staffMember WHERE smEmail = '{$email}' AND smPassword = '{$password}'"; //$query = "select staffMemberID, smFirstName from staffMember"; $result_set = oci_parse($conn, $query); oci_execute($result_set); confirm_query($result_set); // there was mysql_num_row which is returns the number of rows in a result. I tried oci_num_rows but got many errors if (oci_fetch($result_set)==1) { $found_user = oci_fetch_array($result_set, OCI_ASSOC+OCI_RETURN_NULLS); //set session variables if user found $_SESSION['logged_in'] = "yes"; $_SESSION['firstName'] = $found_user['smFirstName']; $_SESSION['staffMemberID'] = $found_user['staffMemberID']; redirect_to("staffArea.php"); } else { $message = "Email / Password combination incorrect.<br /> Please make sure your caps lock key is off and try again."; } } } else { // Form has not been submitted. if (isset($_GET['logout']) && $_GET['logout'] == 1) { $message = "You are now logged out."; } if (isset($_GET['error']) && $_GET['error'] == 1) { $message = "Sorry but you must be logged in to view that page."; } $email = ""; $password = ""; } ?> The code below is for my sessionUser Page that the above script links to for its session commands. The function staff_confirm_logged_in() is where my codes getting caught at. I get the error associated with that function below every time if i don't comment out my session going to the next page. <?php session_start(); function staffLogged_in(){ if(isset($_SESSION['staffMemberID']) && ($_SESSION['logged_in'] =="yes") && isset($_SESSION['firstName'])){ return true; } else { return false; } } function staff_confirm_logged_in() { if (!staffLogged_in()) { redirect_to("staffLogin.php?error=1"); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/205479-php-script-login-script-using-oracle-11g-wont-work-sessions-not-working/ Share on other sites More sharing options...
Mchl Posted June 21, 2010 Share Posted June 21, 2010 And what error it is that you get? Quote Link to comment https://forums.phpfreaks.com/topic/205479-php-script-login-script-using-oracle-11g-wont-work-sessions-not-working/#findComment-1075282 Share on other sites More sharing options...
mboley370 Posted June 21, 2010 Author Share Posted June 21, 2010 Its just using my error I have setup which would be this. Sorry but you must be logged in to view that page It says this, because it uses this in the next page to load the page. It makes sure that the users is logged in. At the top before anything it makes sure with a funciton that points to this code. function staff_confirm_logged_in() { if (!staffLogged_in()) { redirect_to("staffLogin.php?error=1"); } The error jumps back to my staffLogin.php page where it spits out the error for error=1 which is error Sorry but you must be logged in to view that page So its getting to the next page, but failing to use sessions and I tested this because if i edit out the sessions on the next page and to check if my user is logged in. I get to the next page. Without commenting anything about sessions it shows me the error that i am not logged in. Quote Link to comment https://forums.phpfreaks.com/topic/205479-php-script-login-script-using-oracle-11g-wont-work-sessions-not-working/#findComment-1075284 Share on other sites More sharing options...
mboley370 Posted June 22, 2010 Author Share Posted June 22, 2010 I figured it out. Quote Link to comment https://forums.phpfreaks.com/topic/205479-php-script-login-script-using-oracle-11g-wont-work-sessions-not-working/#findComment-1075403 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.