Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Feb 2010
    Posts
    30
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Not reading userid from sesh

    Hi guys, my project is moving along.

    This code is supposed to allow a user (userid should be taken from the session) to select a race from another table via a drop down box and submit it to update the record.

    I have got it to display and show the races, and when i submit it does go to the add section but does not actually do anything.
    I think it is to do with it not receiving a user from the sesh.

    PHP Code:
    <?php
    require("includes/sesh.inc");
    require(
    "includes/header.inc");
    require(
    "includes/db.inc");
    require(
    "includes/menu.inc");

    $currentuser $_SESSION['uid'];


    echo 
    "<h1>Run Selection</h1>";
    echo 
    $currentuser;
    echo 
    "</br>";
    echo 
    "</br>";

    if(isset(
    $_GET['add']))
    {
    $i $_POST['rid'];
    $r $_POST['rname'];

    $query"UPDATE userdetails
    SET racetrainingfor = '($r)'
    //WHERE userdetails.userid = $currentuser"
    ;
    mysql_query($query);
    echo 
    "<p>Race Selected</p>";
    }



    echo 
    "<form action='selectrun.php?add=yes' method='post'>";
    echo 
    "<select name='rname'>";

    $query1 "SELECT * FROM rundetails";
    $result mysql_query($query1);

    while (
    $row mysql_fetch_array($result))
    {
    extract($row);

    echo
    "<option value='".$runid."'> ".$runname." </option>";

    }
    echo 
    "</select>";
    echo 
    "<input type='submit' value='Select Race'></p>";
    echo 
    "</form>";



    require(
    "includes/footer.inc");
    ?>

  • #2
    met
    met is offline
    Regular Coder
    Join Date
    Oct 2009
    Location
    United Kingdom
    Posts
    728
    Thanks
    4
    Thanked 119 Times in 119 Posts
    so would it not have been more useful to provide sesh.inc code as well?

    check session_start() at the very top and post further code

    PHP Code:
    $query"UPDATE userdetails
    SET racetrainingfor = '($r)'
    WHERE userdetails.userid = $currentuser"
    //you had a comment in the query, was that intended?
    mysql_query($query); 
    echo 
    "<p>Race Selected</p>";


  • #3
    New Coder
    Join Date
    Feb 2010
    Posts
    30
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Hi thanks.

    That comment was there as I was trying to get it to work regardless, so I would like that where clause to be included.

    Also me sesh is;

    PHP Code:
    <?php
    session_start
    ();
      if (!isset(
    $_SESSION['auth'] ) OR $_SESSION['auth']!= "yes")  
      {
         
    header("Location: login.php");
         exit();
      }
    ?>
    Jama

  • #4
    New Coder
    Join Date
    Feb 2010
    Posts
    30
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Also this is where uid is defined in my login script.
    I know this method works as i have used lev elsewhere;

    PHP Code:
    <?php
    session_start
    ();
    session_register('auth');  
    session_register('lev');  
    session_register('uname'); 
    session_register('uid'); 
                     
    require(
    "includes/header.inc");
    //if they have chosen to login
    if(isset($_GET['do'])) {
    include(
    "includes/db.inc");
    $fuser $_POST['fusername'];
    $fpass $_POST['fpassword'];
    $query "SELECT * FROM userdetails WHERE username=LOWER('$fuser') AND password=LOWER('$fpass')";
    $result mysql_query($query);
    $num mysql_num_rows($result);
    if (
    $num==1) {
    $row mysql_fetch_array($result);
    extract($row);
    $_SESSION['auth'] = "yes";
    $_SESSION['uname'] = $fuser;
    $_SESSION['lev'] = $accesslevel;
    $_SESSION['uid'] = $userid;
    include(
    "includes/menu.inc");
    }
    //details not found in database as entered
    else {
    echo 
    "<p>Login details are incorrect.</p>";
    include(
    "includes/login_form.inc");
    }
    }
    //not tried to login
    else {
    include(
    "includes/login_form.inc");
    }



    require(
    "includes/footer.inc");


    ?>


  •  

    Posting Permissions

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