SitePoint Sponsor |
|
User Tag List
Results 1 to 11 of 11
-
Feb 17, 2006, 00:10 #1
- Join Date
- Oct 2005
- Location
- in front of my computer
- Posts
- 571
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
passing session var from one page to another
to all the Gurus in PHP,
please help...
im stack in my problem passing variable to another page....
ok..i have this bill.php...
PHP Code:include ("conf.inc.php");
session_start();
if (!empty($HTTP_POST_VARS)) {
$mode = $HTTP_POST_VARS[mode];
}
if (!isset($mode)) {
if (!$auth->checkloginhere()) {
bill_login();
}
else {
bill_index();
}
} else {
switch ($mode) {
case "login":
VerifyLogin($HTTP_POST_VARS[uname],$HTTP_POST_VARS[passwd]);
break;
case "logout":
$_SESSION['username'] = '';
//$auth->logout_regusers();
$auth->logout();
bill_login();
break;
case "adminuser":
admin_users();
break;
case "wapdownloads" :
//$smarty->assign("username",$_SESSION['username']);
wapdownloads($sortq,$_SESSION['username']);
break;
case "home" :
bill_index();
break;
default :
bill_index();
break;
}
}
function bill_index() {
Global $smarty, $db;
if ($_SESSION['username']!='') {
$smarty->assign("username",$_SESSION['username']);
}
$smarty->assign("username",$_SESSION['username']);
$smarty->display("bills/main.html");
}
function bill_login() {
GLOBAL $smarty;
$smarty->display('bills/login.html');
return true;
}
function VerifyLogin($uname,$passwd) {
Global $smarty,$auth;
if (!$auth->login($uname,$passwd)) {
$smarty->assign("alert_msg","<script>alert(\"Invalid Login, try again...\")</script>");
$smarty->display('bills/login.html');
} else {
$smarty->assign("username",$_SESSION['username']);
bill_index();
}
}
//here is where the problem is....the session variable is not being passed...
function wapdownloads($sortq) {
Global $smarty, $db;
if ($_SESSION['username']!="") {
bill_login();
}else{
$smarty->assign("username",$_SESSION['username']);
$smarty->assign("log","<div id=\"teaser\"><h2>User : ".$_SESSION['username']."</h2><a href='bill.php?mode=logout'>Log-out</a></div>");
//some code here...................
$smarty->display("bills/wapdownloads.html");
return true;
}
}
PHP Code:function checkloginhere() {
global $HTTP_COOKIE_VARS;
$secret_word = 'mmxthebest';
$cookie = $_COOKIE['mysite'];
$split = explode(":", $cookie);
$uname = $split[0];
$hash = $split[1];
$hash2 = md5($secret_word . $uname);
$_SESSION['username'] = $uname;
if($hash2 == $hash){
return 1;
} else {
return 0;
}
} //end checkLogin()
please help me here.....
-
Feb 17, 2006, 00:22 #2
-
Feb 17, 2006, 00:23 #3PHP Code:
//session_start();
PHP Code:session_start();
-
Feb 17, 2006, 00:36 #4
-
Feb 17, 2006, 00:41 #5
And the Problem is? (You know you can edit your previous post.)
-
Feb 17, 2006, 00:54 #6
-
Feb 17, 2006, 01:01 #7
- Join Date
- Nov 2005
- Posts
- 241
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Don't you need a } right after
PHP Code://some code here...................
$smarty->display("bills/wapdownloads.html");
return true;
}
-
Feb 17, 2006, 01:12 #8
-
Feb 17, 2006, 22:02 #9
- Join Date
- Nov 2005
- Posts
- 241
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by dscriptor
-
Feb 18, 2006, 08:43 #10
-
Feb 18, 2006, 09:55 #11
Seems you need to do some debugging.
Are any other SESSION variables in place? You can see by doing the
var_dump($_SESSION);
If your session is empty at all, it means you have troubles with session initialization, otherwise - somewhere else.Sergey Neskhodovskiy
www.WebProGuide.com
SEO Articles, news, software reviews,
resources, experts' bios and more!
Bookmarks