Results 1 to 3 of 3
  1. #1
    bliss
    Guest

    Default php session variables

    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)

  2. #2
    stu120404
    Guest

    Default Re: php session variables

    If you donít get any replyís/help to this thread try posting this question here:

    http://www.webdeveloper.co.nz/

    Good luck

  3. #3
    bliss
    Guest

    Default Re: php session variables

    sweet

Similar Threads

  1. draw using variables from spreadsheet
    By felix in forum PressF1
    Replies: 0
    Last Post: 15-01-2004, 01:36 PM
  2. session variables expire
    By sc0ut in forum PressF1
    Replies: 1
    Last Post: 28-11-2003, 01:55 PM
  3. Setting environment variables
    By airdale in forum PressF1
    Replies: 4
    Last Post: 27-10-2003, 08:56 PM
  4. Memory cookies/Session Variables
    By Random_User in forum PressF1
    Replies: 0
    Last Post: 28-06-2002, 12:19 PM
  5. Replies: 1
    Last Post: 22-12-2001, 02:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •