inspire Posted September 19, 2007 Share Posted September 19, 2007 [move]How to solve it ???[/move] when i pass the session , the sesion variable is not display in new-course.php here the code.....pls help i am using php 4.0 page index.php <? session_start(); mysql_connect("localhost","trainee","123") or die ("Unable to connect to the server"); mysql_select_db("gddatab"); if(isset($HTTP_POST_VARS['usernameh'])) { $uname=$HTTP_POST_VARS['usernameh']; $upass=$HTTP_POST_VARS['passwordh']; $sql=("select * from user where s_username ='$uname' and s_password ='$upass'"); $result=mysql_query($sql); $recordset=mysql_fetch_assoc($result); $recordset_count=mysql_num_rows($result); if($recordset_count==1) { $_SESSION['name'] = $recordset['s_name']; echo $_SESSION['name']; echo '<script>window.location.href=\'new-course.php\'</script>'; } else { session_destroy(); $failed=true; } } new-course.php <? session_start(); ?> <!doctype html public "-//W3C//DTD HTML 4.0 //EN"> <html> <head> <title></title> </head> <body > <? echo $_SESSION['name']; ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/69835-interesting-session-error/ Share on other sites More sharing options...
ToonMariner Posted September 19, 2007 Share Posted September 19, 2007 I take it you are using an older version of php (the $HTTP_POST_VARS suggest you are). If that is teh case then you may need to use sesion_register to set a session var. Link to comment https://forums.phpfreaks.com/topic/69835-interesting-session-error/#findComment-350809 Share on other sites More sharing options...
teng84 Posted September 19, 2007 Share Posted September 19, 2007 OR DO THIS print_r($_SESSION);in your new-course.php then post the result here Link to comment https://forums.phpfreaks.com/topic/69835-interesting-session-error/#findComment-350812 Share on other sites More sharing options...
inspire Posted September 19, 2007 Author Share Posted September 19, 2007 still the sesion variable is not display in new-course.php ??? Link to comment https://forums.phpfreaks.com/topic/69835-interesting-session-error/#findComment-350823 Share on other sites More sharing options...
inspire Posted September 19, 2007 Author Share Posted September 19, 2007 [move]How to solve it ???[/move] when i pass the session , the sesion variable is not display in new-course.php here the code.....pls help i am using php 4.0 page index.php <? session_start(); mysql_connect("localhost","trainee","123") or die ("Unable to connect to the server"); mysql_select_db("gddatab"); if(isset($HTTP_POST_VARS['usernameh'])) { $uname=$HTTP_POST_VARS['usernameh']; $upass=$HTTP_POST_VARS['passwordh']; $sql=("select * from user where s_username ='$uname' and s_password ='$upass'"); $result=mysql_query($sql); $recordset=mysql_fetch_assoc($result); $recordset_count=mysql_num_rows($result); if($recordset_count==1) { $_SESSION['name'] = $recordset['s_name']; echo $_SESSION['name']; echo '<script>window.location.href=\'new-course.php\'</script>'; } else { session_destroy(); $failed=true; } } new-course.php <? session_start(); ?> <!doctype html public "-//W3C//DTD HTML 4.0 //EN"> <html> <head> <title></title> </head> <body > <? echo $_SESSION['name']; ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/69835-interesting-session-error/#findComment-350848 Share on other sites More sharing options...
remlabm Posted September 19, 2007 Share Posted September 19, 2007 try changing it from $_SESSION['name'] to $_SESSION['user_name'] or something.... watch common names in sessions such as name, id, public Link to comment https://forums.phpfreaks.com/topic/69835-interesting-session-error/#findComment-350875 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.