Jump to content

Help with $_SESSION['id']


Bike Racer

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.