problem with session????
Posted: Wed Nov 11, 2009 5:32 am
i'm beginner in session handling. i have read manual for session_start() function but can't quite grasp it's content. try to code some but end up like this:
http://test152.insanez.com/index.php?lang=eng&page=home
please help me, at least show me some clue or can any one explain to me how session work.
here's my script:
[index.php]
<?php
session_start();
if (!isset($_GET["page"]))
{
$_GET["page"]="home";
}
$_GET["lang"]="eng";
require 'class/request.class.php';
require 'class/common.class.php';
require 'class/mail.class.php';
include 'include/control.inc.php';
?>
<!-- some html crap --!>
----- <?php
include "include/navigation.inc.php";
?> -----
[end index.php]
problem may raise in this file
[control.inc.php]
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
//session_start();
$forms = array();
$mail;
function formSubmit($name){
global $forms, $mail;
if(isset($_POST[$name]) && isset($_SESSION[$name])){
$forms[$name] = $_SESSION[$name];
if (!$forms[$name]->extractMail($mail)){
return false;
}
if (is_a($forms[$name]->getElement($name),"SpamGuard")){
if($forms[$name]->getElement($name)->validate($_SESSION['security_code'],$_SESSION['start_time'])){
$mail->sendMail();
$_GET['page'] = 'congrat';
unset($_SESSION[$name]);
unset($forms[$name]);
return true;
}
}elseif (is_a($forms[$name]->getElement($name),"SubmitButton")) {
$mail->sendMail();
unset($_SESSION[$name]);
unset($forms[$name]);
return true;
}
}
return false;
}
[end control.inc.php]
thanx for all who helped.
http://test152.insanez.com/index.php?lang=eng&page=home
please help me, at least show me some clue or can any one explain to me how session work.
here's my script:
[index.php]
<?php
session_start();
if (!isset($_GET["page"]))
{
$_GET["page"]="home";
}
$_GET["lang"]="eng";
require 'class/request.class.php';
require 'class/common.class.php';
require 'class/mail.class.php';
include 'include/control.inc.php';
?>
<!-- some html crap --!>
----- <?php
include "include/navigation.inc.php";
?> -----
[end index.php]
problem may raise in this file
[control.inc.php]
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
//session_start();
$forms = array();
$mail;
function formSubmit($name){
global $forms, $mail;
if(isset($_POST[$name]) && isset($_SESSION[$name])){
$forms[$name] = $_SESSION[$name];
if (!$forms[$name]->extractMail($mail)){
return false;
}
if (is_a($forms[$name]->getElement($name),"SpamGuard")){
if($forms[$name]->getElement($name)->validate($_SESSION['security_code'],$_SESSION['start_time'])){
$mail->sendMail();
$_GET['page'] = 'congrat';
unset($_SESSION[$name]);
unset($forms[$name]);
return true;
}
}elseif (is_a($forms[$name]->getElement($name),"SubmitButton")) {
$mail->sendMail();
unset($_SESSION[$name]);
unset($forms[$name]);
return true;
}
}
return false;
}
[end control.inc.php]
thanx for all who helped.