Results 1 to 2 of 2

Thread: sessions

  1. #1
    Join Date
    Aug 2006
    Posts
    1

    Unanswered: sessions

    im new to php. I have this login script that works fine just trying ot add a session variable to get the data from the field usertype.

    ive tried the code below im my script but getting parser errors the parts i have added that are not functioning are

    $usertype = $_POST['usertype'];

    $_SESSION['valid_type'] = get($usertype, "admin");

    Just want to know how to get this session to work correctly like the others do any help appreciated

    full code below.

    PHP Code:
     <?
    include "functions/include_fns.php";
    if (isset(
    $_POST['username']) && isset($_POST['password'])) {

    $username $_POST['username'];
    $password $_POST['password'];
    $usertype $_POST['usertype'];

    if (
    login($username$password"admin")) {

    $sql

    $_SESSION
    ['valid_user'] = $username;
    $_SESSION['valid_name'] = getname($username"admin");
    $_SESSION['valid_type'] = get($usertype"admin");

    if (isset(
    $_POST['url']) && !empty($_POST['url'])) {
    $go_url "".$url;
    header("Location: $go_url");
    } else {
    header("Location: home.php");
    }
    exit;
    } else {
    //status = 0: Incorrect Username or password
    //status = 1: Session has timed out or your are not logged in
    header("Location: index.php?status=0");
    exit;
    }
    } else {
    header("Location: index.php?status=0");
    exit;
    }
    ?>
    Last edited by cougarslam; 08-14-06 at 11:03.

  2. #2
    Join Date
    Jan 2005
    Posts
    68
    i see two problems:

    1.what is $sql doing? it at least needs a semicolon

    2.put
    if(!isset($_SESSION)){session_start();}
    before
    $_SESSION['valid_user'] = $username;

Posting Permissions

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