breeze351
asked on
Why would an idex page show diffrent sceens?
I'm having a problem that I think is the server that I'm using.
When you log in to the site some times it works, other times, it displays php code!
I've contacted "HOSTING24.COM" and they are telling me that it's the php code.
I can't understand that answer. If php executes line by line, how could the results be different?
I've attached a word file that contains the print screens. If you want the site is "mrbreeze.net"
Thanks
Glenn
Screens.doc
When you log in to the site some times it works, other times, it displays php code!
I've contacted "HOSTING24.COM" and they are telling me that it's the php code.
I can't understand that answer. If php executes line by line, how could the results be different?
I've attached a word file that contains the print screens. If you want the site is "mrbreeze.net"
Thanks
Glenn
Screens.doc
It's telling you what the problem is, you are referencing an index in the Security array that doesn't exist.
I think it's referencing the index named Security and I'm wondering if that index is in $_COOKIE or in $_SESSION.
Check menu_inc.php on line 46
Check menu_inc.php on line 46
Also
Notice: Undefined index: Menu_No in /home/mrbreeze/public_html /menu_inc. php on line 161
Notice: Undefined index: Menu_No in /home/mrbreeze/public_html
ASKER
I think I got this. Here is the original code from the top of "index.php":
<?php
include 'Session_Start.php';
include 'db_connect_inc.php';
include 'menu_inc.php';
echo "<div id = \"map_content\">";
// If login not set
// Set login for "Visitor"
if (!isset($_SESSION['Securit y']))
{
$_SESSION['User'] = 'VISITOR';
$_SESSION['Password'] = 'VISITOR';
$_SESSION['First_Name'] = 'Visitor';
$_SESSION['Last_Name'] = 'VIsitor';
$_SESSION['E_Mail'] = '';
$_SESSION['Security'] = 1;
$_SESSION['P_Format'] = 1;
}
$_SESSION['Menu_No'] = 1;
$_SESSION['Last_Page'] = "index.php";
?>
If I move the inclusions below the if statement like this:
<?php
// If login not set
// Set login for "Visitor"
if (!isset($_SESSION['Securit y']))
{
$_SESSION['User'] = 'VISITOR';
$_SESSION['Password'] = 'VISITOR';
$_SESSION['First_Name'] = 'Visitor';
$_SESSION['Last_Name'] = 'VIsitor';
$_SESSION['E_Mail'] = '';
$_SESSION['Security'] = 1;
$_SESSION['P_Format'] = 1;
}
include 'Session_Start.php';
include 'db_connect_inc.php';
include 'menu_inc.php';
echo "<div id = \"map_content\">";
$_SESSION['Menu_No'] = 1;
$_SESSION['Last_Page'] = "index.php";
?>
It should work?
<?php
include 'Session_Start.php';
include 'db_connect_inc.php';
include 'menu_inc.php';
echo "<div id = \"map_content\">";
// If login not set
// Set login for "Visitor"
if (!isset($_SESSION['Securit
{
$_SESSION['User'] = 'VISITOR';
$_SESSION['Password'] = 'VISITOR';
$_SESSION['First_Name'] = 'Visitor';
$_SESSION['Last_Name'] = 'VIsitor';
$_SESSION['E_Mail'] = '';
$_SESSION['Security'] = 1;
$_SESSION['P_Format'] = 1;
}
$_SESSION['Menu_No'] = 1;
$_SESSION['Last_Page'] = "index.php";
?>
If I move the inclusions below the if statement like this:
<?php
// If login not set
// Set login for "Visitor"
if (!isset($_SESSION['Securit
{
$_SESSION['User'] = 'VISITOR';
$_SESSION['Password'] = 'VISITOR';
$_SESSION['First_Name'] = 'Visitor';
$_SESSION['Last_Name'] = 'VIsitor';
$_SESSION['E_Mail'] = '';
$_SESSION['Security'] = 1;
$_SESSION['P_Format'] = 1;
}
include 'Session_Start.php';
include 'db_connect_inc.php';
include 'menu_inc.php';
echo "<div id = \"map_content\">";
$_SESSION['Menu_No'] = 1;
$_SESSION['Last_Page'] = "index.php";
?>
It should work?
No, that won't work
session_start() needs to be the first line
The error means $_SESSION['Security'] and menu_no is not being set but you are referencing it somewhere else in the code.
In your code above you are only checking if it hasn't been set.
session_start() needs to be the first line
The error means $_SESSION['Security'] and menu_no is not being set but you are referencing it somewhere else in the code.
In your code above you are only checking if it hasn't been set.
ASKER
Goctha
I move Session_Start.php to line 1.
I just grabbed this code and modified it real quick to get an answer.
I move Session_Start.php to line 1.
I just grabbed this code and modified it real quick to get an answer.
It's a common question, hence this article:
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11909-PHP-Sessions-Simpler-Than-You-May-Think.html
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11909-PHP-Sessions-Simpler-Than-You-May-Think.html
@breeze - the error is not in your index file - it is in menu_inc.php, specifically lines 46 & 161. There is also a problem triggering a syntax error on line 61 of the same file.
It might be worth addressing this, too. To a certain extent the PHP errors may be causing the validation errors, but it is hard to tell since the validator does only a single GET request.
http://validator.w3.org/check?uri=http%3A%2F%2Fmrbreeze.net%2F&charset=%28detect+automatically%29&doctype=Inline&group=0
Looking at the "view source" I see a doctype declaration on line 104, leading me to believe that there are organizational errors in the PHP script that generates the HTML. Here is the organization I often use:
http://validator.w3.org/check?uri=http%3A%2F%2Fmrbreeze.net%2F&charset=%28detect+automatically%29&doctype=Inline&group=0
Looking at the "view source" I see a doctype declaration on line 104, leading me to believe that there are organizational errors in the PHP script that generates the HTML. Here is the organization I often use:
<?php
error_reporting(E_ALL);
require_once('common.php');
/* PROGRAM LOGIC CREATES ALL VARIABLES HERE */
require_once('header.php');
require_once('template.php');
require_once('footer.php.);
By way of explanation, common.php handles all of the "infrastructure" connecting to the data base, starting the session, etc. The common.php script contains all the class and function definitions (or auto-loaders for these). After that the program logic runs, usually using the request variables to query the data base, call the APIs, read external files, analyze and set the cookies, etc. The program logic sets all of the variables that will be needed in the HTML document. Once that is done the web page can be built. header.php does exactly what you would think. template.php loads the web page template, usually a HEREDOC string, and thereby creates an HTML document that contains the variables created by the program logic. footer.php, like header.php is pretty obvious. These last three include() files are the only things that produce browser output. By keeping the scripts modular and in a predictable order, I'm able to keep my work organized, testable and easy to debug.
ASKER
Ray
This is a menu/index page. There is no get.
I've read the article on $_SESSION vars. What I can't still understand is why the page will load correctly and sometimes I get the error messages. When I hit re-fresh on the browser it loads correctly.
Also, what is the diff between $isset and $empty?
I also discovered something else. I haven't accessed the page since yesterday, however it seemed that the $_SESSION vars were still alive. I thought they expired in 25 minutes?
Thanks
Glenn
This is a menu/index page. There is no get.
I've read the article on $_SESSION vars. What I can't still understand is why the page will load correctly and sometimes I get the error messages. When I hit re-fresh on the browser it loads correctly.
Also, what is the diff between $isset and $empty?
I also discovered something else. I haven't accessed the page since yesterday, however it seemed that the $_SESSION vars were still alive. I thought they expired in 25 minutes?
Thanks
Glenn
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.