I am trying to set a cookie or a session depening on user selection
I can pass the session variable anywhere except into the query that give me the users name.
<?php
session_start();
//Connect To Database
mysql_connect("localhost","flightfe_homchz","yankee");
mysql_select_db("flightfe_bizstoredb");
//Lets See who is here
//Did they bring any cookies to share with us?
if (!isset ($_COOKIE['login']) || ($_SESSION['user']))
{
require_once ("Pages/main.php");
}
else if (isset($_COOKIE['login']))
{
$userid = $_COOKIE['login'];
//Let's See who this is
$sql = mysql_query("SELECT username FROM bs_user_member WHERE id = '$userid'");
if (mysql_num_rows($sql) > "0")
{
while ($row = mysql_fetch_array($sql))
{
$logeduname = $row['username'];
}
}
}
else
{
$userid = $_SESSION['user'];
//Let's See who this is
$sql = mysql_query("SELECT username FROM bs_user_member WHERE id = '$userid'");
if (mysql_num_rows($sql) > "0")
{
while ($row = mysql_fetch_array($sql))
{
$logeduname = $row['username'];
}
}
}
require_once ("Pages/main.php");
?>
THe pages load as they are suposed to depending on cookie or variable, except I cannot get the query to pass the variable when using the session.
Any ideas.