> $v_dec["page_no"] = $page_no; > Which means that $v_dec will always equal nothing, because at the > point at which the file is included, $page_no hasn't been set to > anything at all. You mean this will unset $v_dec["page_no"]? This explains why at reload of index.php happens what happend. But how to solve it? I _have_ to store some variables anywhere.
The session management at this point is rudimentary. I wrote it that way, that it works for now, i.e. building the query pages. This is of course not the final session management. At login I just write the session_id() into the table without checking if the user already owns a session. I left it to the end of work. So maybe it is not a problem of login_status()?
function check_user($check_name, $check_passw) { $connect = @OCILogon("", "", "");
if(!$connect)
{
$err_oci = OCIError();
echo "(2) No connection - OCIError(): ".$err_oci["message"];
echo "<p>";
}
else
{
$sql_check = "SELECT count(*) AS count FROM user_web
WHERE user_name = '".$check_name."' AND user_pass = '".$check_passw."'";
$stmt = OCIParse($connect, $sql_check);
OCIExecute($stmt);
while(OCIFetch($stmt)) { $res_check = (int) OCIResult($stmt, "COUNT"); }
if(!$res_check == 1)
{
OCIFreeStatement($stmt);
OCILogOff($connect);
return(false);
}
else
{
$sql_check = "SELECT user_pid FROM user_web
WHERE user_name = '".$check_name."' AND user_pass = '".$check_passw."'";
$stmt = OCIParse($connect, $sql_check);
OCIExecute($stmt);
while(OCIFetch($stmt)) { $user_pid = (int) OCIResult($stmt, "USER_PID"); } OCIFreeStatement($stmt); OCILogOff($connect); return($user_pid); } } }
function login($user_pid, $session_id) { $connect = @OCILogon("", "", "");
if(!$connect)
{
$err_oci = OCIError();
echo "(2) No connection - OCIError(): ".$err_oci["message"];
echo "<p>";
}
else
{
$sql_login = "UPDATE user_web SET user_session = '".$session_id."'
WHERE user_pid = '".$user_pid."'";
$stmt = OCIParse($connect, $sql_login);
OCIExecute($stmt);
}
OCIFreeStatement($stmt);
OCILogOff($connect);
}
function login_status($session_id) { $connect = @OCILogon("", "", "");
if(!$connect)
{
$err_oci = OCIError();
echo "(2) No connection - OCIError(): ".$err_oci["message"];
echo "<p>";
}
else
{
$sql_session_id = "SELECT count(user_session) FROM user_web
WHERE user_session = '".$session_id."'";
$stmt = OCIParse($connect, $sql_session_id);
OCIExecute($stmt);
while(OCIFetch($stmt)) { $res_status = OCIResult($stmt, "COUNT(USER_SESSION)"); } if(!$res_status == 1) { return(false); } else { return($res_status); } } OCIFreeStatement($stmt); OCILogOff($connect); }
Now I changed $page_no to $v_dec["page_no"] with the same result.
If through submitting a form index.php is reloaded, but the value in $v_dec["page_no"] get lost.
#manage.php <?php $session_id = session_id(); include('variables.php'); include('functions.php');
if(!isset($v_dec["page_no"])) { $v_dec["page_no"] = "login"; }
if(!(login_status($session_id)) == 1) { $v_dec["page_no"] = "login"; }
/* User logged in? */ if(!($v_dec["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; $v_dec["page_no"] = "start_auswahl"; } else { $res_login = 0; $res_login_text = "Login incorrect."; } } else { $res_login = 0; $res_login_text = "Insert Login AND Passwort."; } } else { $res_login = 0; } if($res_login == 0) { include('b_login.php'); } }
/* if page = wells, springs, precipitation, surface used überprüfen, ob Formulare abgeschickt */ if($v_dec["page_no"] == "start_select") { if(isset($_POST['b_start_select'])) { if(!($_POST['sources'] == "")) { switch($_POST['sources']) { case "wells": $v_dec["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_auswahl"; } } } }
if(!($v_dec["page_no"] == "login")) { switch($v_dec["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('foot.php'); }
?>
Thank you, TorstenRichard Davey schrieb:
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php