I have read the other questions relating to this and it does not answer my question or produced any troubleshooting results. I have a login in page. It functions fine and it is starting the session and displays nothing. even when I put an echo"Hello World"; nothing shows. and it still shows as being in login.php not products.php.
Here is the code: session start (there is not space before the session_start function:
<?php
session_start();
/* connection info */
include("connection.php");
?>
Checks for Blank fields:
if(isset($_POST['submitted']) and $_POST['submitted'] == "yes")
{
foreach($_POST as $field => $value)
{
if(empty($value))
{
$blank_array[] = $field;
}
else
{
$good_data[$field] = strip_tags(trim($value));
}
}
if(@sizeof($blank_array) > 0)
{
$message = "<p style='color: red; margin-bottom: 0;
font-weight: bold'>
You didn't fill in one or more required fields.
You must enter:
<ul style='color: red; margin-top: 0;
list-style: none' >";
/* display list of missing information */
foreach($blank_array as $value)
{
$message .= "<li>$value</li>";
}
$message .= "</ul>";
echo $message;
extract($good_data);
include("login.inc");
exit();
}
Checks for format consistency:
foreach($_POST as $field => $value)
{
if(!empty($value))
{
$user_patt = "/^[A-Za-z0-9]{3,20}$/";
$pass_patt = "/^(?=.*\d)(?=.*[A-Za-z])[0-9A-Za-z!@#$%]{6,12}$/";
if(preg_match("/user/i",$field))
{
if(!preg_match($user_patt,$value))
{
$error_array[] = "$value is an invalid $field";
}
}
if (preg_match("/word/i",$field))
{
if(!preg_match($pass_patt, $value))
{
$error_array[] = "Invalid $field";
}
}
}
$good_data[$field] = strip_tags(trim($value));
}
if(@sizeof($error_array) > 0)
{
$message = "<ul style='color: red; list-style: none' >";
foreach($error_array as $value)
{
$message .= "<li>$value</li>";
}
$message .= "</ul>";
echo $message;
extract($good_data);
include("login.inc");
exit();
}
$_SESSION variable:
else
{
foreach($good_data as $field => $value)
{
$good_data[$field] = mysqli_real_escape_string($cxn,$value);
}
$sql = "SELECT * from UserInfo where user_id = '$good_data[user_id]' and
password = '$good_data[password]'";
$result = mysqli_query($cxn,$sql) or die("Couldn't find UserInfo: " . mysqli_error($cxn));
if ( mysqli_num_rows($result) > 0)
{
$sql2 = "UPDATE TimeStamp SET user_id = '$good_data[user_id]', time = CURRENT_TIMESTAMP";
$result2 = mysqli_query($cxn,$sql2) or die("Couldn't update TimeStamp: " . mysqli_error($cxn));
$_SESSION["variable"] = "condition";
header("location: products.php");
}
}
}
else
{
$user_id = "";
$password = "";
include("login.inc");
}
?>
products.php page:
<?php
session_start();
include(connection.php);
if(!isset($_SESSION['variable']) or $_SESSION['variable'] != "condition")
{
header("location: login.php");
exit();
}
?>