Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 09-18-2007, 12:01 AM session error
Novice Talker

Posts: 9
Trades: 0
when i pass the session , the sesion variable is not display in new-course.php

here the code.....pls help

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>
INSPIRE is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-18-2007, 12:04 AM Re: session error
Novice Talker

Posts: 9
Trades: 0
when the login success , the new-course.php page not display the session that i pass in index.php.

when i test echo the $_SESSION['name'] in index.php it display it.but when it is pass to the next page , the echo not work.
INSPIRE is offline
Reply With Quote
View Public Profile
 
Old 09-18-2007, 02:39 AM Re: session error
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
$_SESSION variables can be tricky. Make sure your session_start() is right at the beginning of the new-course page with no whitespace or anything.

Also if your using PHP greater than 4.1.0 then HTTP_POST_VARS shouldn't be used as its now deprecated - $_POST should be used.
maxxximus is offline
Reply With Quote
View Public Profile
 
Old 09-18-2007, 04:09 AM Re: session error
Novice Talker

Posts: 9
Trades: 0
I am using php ver 4.0.5 in windows environment.

The problem still unsolve.
INSPIRE is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to session error
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.34977 seconds with 12 queries