Bike Racer Posted April 21, 2008 Share Posted April 21, 2008 I'm having problems with the data from $_SESSION['id'] carrying over to the next page. Script of first page------- <?php require_once("Connections/testserver.php"); session_start(); //Catch Field Data $userid = $_POST['userid']; $password = $_POST['password']; $submitted = $_POST['submitted']; if ($userid && $password) { ///////////////////////////////////////////// $query = sprintf("SELECT * FROM night where user_name='$userid' and user_password = '$password'"); $result = mysql_query($query); $rowAccount = mysql_fetch_array($result); ///////////////////////////////////////////// } if ($rowAccount) { $_SESSION['id'] = $rowAccount['user_id']; header("location:success.php"); exit; }elseif($submitted){ echo "You don't exist on our database"; } ?> and for the second page----------- <?php require_once("Connections/testserver.php"); session_start; if (!isset($_SESSION['id'])){ header("location: mylogin.php"); exit; } $id = $_SESSION['id']; //////////////////////////// $query =sprintf("SELECT * FROM night where user_id='1'"); $result =mysql_query($query); $rowAccount =mysql_fetch_array($result); ///////////////////////////// ?> Link to comment https://forums.phpfreaks.com/topic/102182-help-with-_sessionid/ Share on other sites More sharing options...
DarkWater Posted April 21, 2008 Share Posted April 21, 2008 On the second page, you have only session_start, but you need session_start();, because it's a function. =) Simple error. I don't know why PHP didn't flag it or something. Link to comment https://forums.phpfreaks.com/topic/102182-help-with-_sessionid/#findComment-523018 Share on other sites More sharing options...
Bike Racer Posted April 21, 2008 Author Share Posted April 21, 2008 Missed () after many times of re-trying the script. Still doesn't work though. Any other ideas? Link to comment https://forums.phpfreaks.com/topic/102182-help-with-_sessionid/#findComment-523034 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.