"global" variables
| From: | Torsten Lange | Date: | Mon, 01 Mar 2004 16:48:39 +0000 |
| Subject: | "global" variables | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-33229@lists.php.net to get a copy of this message | ||
Hi,
I build a small web interface to a database.
I include into the index.php the <filepaths> and a <manage.php>:
#index.php
<?php
session_start();
$base_path = "/.../";
include('manage.php');
?>
In <manage.php> I include the <variables.php> and the <functions.php> and then decide on the status of a variable $page_no which further <file.php> has to be included to perfom the query jobs:
#manage.php
<?php
include('variables.php');
include('functions.php');
if(!isset($page_no))
{
$page_no = "login";
}
if(!(login_status($session_id)) == 1)
{
$page_no = "login";
}
// user logged in?
if(!($page_no == "login"))
{
include('head.php');
}
else
{
if(isset($_POST['login']))
{
if(!($_POST['user'] == "") && !($_POST['passw'] ==""))
{
$user_pid = check_user($_POST['user'], $_POST['passw']);
if(($user_pid != false) && (login_status($user_pid) == false))
{
login($user_pid, $session_id);
$res_login = 1;
$page_no = "start_select";
}
else
.
.
.
if($res_login == 0)
{
include('b_login.php');
}
}
if($page_no == "start_select")
{
if(isset($_POST['b_start_select']))
{
if(!($_POST['sources'] == ""))
{
switch($_POST['sources'])
{
case "wells": $page_no = "wells";
break;
case "springs": $page_no = "springs";
break;
case "precipitation": $page_no = "precipitation";
break;
case "surface": $page_no = "surface";
break;
case "used": $page_no = "used";
break;
default: $page_no = "start_select";
}
}
}
}
if(!($page_no == "login"))
{
switch($page_no)
{
case "start_select": include('b_start_select.php');
break;
case "wells": include('b_wells.php');
break;
case "springs": include('b_springs.php');
break;
case "precipitation": include('b_precipitation.php');
break;
case "surface": include('b_surface.php');
break;
case "used": include('b_used.php');
break;
default: echo "If you see this side, please mail to.;
}
include('fuss.php');
}
?>
I declared the $page_no in my
#variables.php as
$v_dec["page_no"] = $page_no.
Now I have the problem that after login and switching to b_start_select.php still $page_no="start_select", because I can print it to this page:
echo $page_no gives: start_select
but
echo $v_dec["page_no"] prints nothing
Second problem: When I pass my selection through the form on the b_start_select.php (form action = "index.php") $page_no again becomes unset. That means I fall back to the login page.
Any suggestions? How in general do you this.
Thank you,
Torsten