shoaibi Posted August 2, 2006 Share Posted August 2, 2006 First please create these files with the names suggested:[Code]<?php//inc.phpob_start();SESSION_START();if($_SESSION['user'] == '' || $_SESSION['pswd'] == ''){ header("Refresh: 5; URL=login.php"); echo "<center>"; echo "<BR> You are trying to access a protected area.<BR>". "You are being redirected to Login Page in 5 seconds";exit;}?><?php//main.phprequire("inc.php");include_once "./cmndb.php";include_once "./pm.php";echo "<BR>Welcome ".$_SESSION['user']; //doesn't display user's ID????//SESSIONS NOT WORKING!!!!!//This is the main page.//Show user's profile info,//Private Messages.//Links to other sections.?><?php//login.phpob_start();SESSOIN_START();require("cmndb.php");if($_POST['action']=="authuser"){ $uname = authuser($_POST['uid'], $_POST['upswd']); if($uname==0 OR $uname==1 OR $uname==2) { $PHP_SELF = $_SERVER['PHP_SELF']; echo "<h1>Authorization failed.</h1> "; if($uname==2) { echo "<BR>Ooops! Your account isn't verified as of yet.<BR>". "<A HREF=\"verify.php\">Click Here</A> to verify your email address.<BR>". "If you haevn't recieved any Verification email <A HREF=\"sendvcode.php\">Click here</A><BR>"; exit; } else if($uname==0) echo "<BR>Ooops! Your provided UserID doesn't even exits!<BR>" ; else echo "<BR>Ooops! Your password isn't correct!<BR>"; echo "Click on the following link to try again.<BR>\n"; echo "<A HREF=\"$PHP_SELF\">Login</A><BR>"; echo "If you're not a member yet, click " . "on the following link to register.<BR>\n"; echo "<A HREF=\"$register_script\">Membership</A>"; exit; } else { $user=$_POST['uid']; $pswd=$_POST['upswd']; $_SESSION['log']=1; $_SESSION['user']=$user; $_SESSION['pswd']=$pswd; header("Location: main.php");/* echo "<center> Welcome back "; echo $_SESSION['user']."<BR> Please wait while you are redirected.<BR>". "You are being redirected to Homepage in 5 seconds";*/ exit; } }?><FORM METHOD="POST" ACTION="<?php echo $PHP_SELF ?>"> <DIV ALIGN="CENTER"><CENTER><input type="hidden" name="action" value="authuser"> <H3>Please log in to access the page you requested.</H3> <TABLE BORDER="1" WIDTH="200" CELLPADDING="2"> <TR> <TH WIDTH="18%" ALIGN="RIGHT" NOWRAP>ID</TH> <TD WIDTH="82%" NOWRAP> <INPUT TYPE="TEXT" NAME="uid" SIZE="8"> </TD> </TR> <TR> <TH WIDTH="18%" ALIGN="RIGHT" NOWRAP>Password</TH> <TD WIDTH="82%" NOWRAP> <INPUT TYPE="PASSWORD" NAME="upswd" SIZE="15"> </TD> </TR> <TR> <TD WIDTH="100%" COLSPAN="2" ALIGN="CENTER" NOWRAP> <INPUT TYPE="SUBMIT" VALUE="LOGIN"> </TD> </TR> </TABLE> </CENTER></DIV></FORM><center><font face="Tahoma" size="2" color="Black"><A HREF="forgotpassword.php">Forgot UserID/Password? </A> <A HREF="register.php">New? </A><BR> <A HREF="sendvcode.php">Haven't Recieved Verification Email? </A></font></center><?phpfunction authuser($uid, $upswd) { global $user_tablename; dbconnect(); $query = "SELECT * FROM $user_tablename WHERE uid = '$uid'"; $result = mysql_query($query); if(!mysql_num_rows($result)) return 0; else { $arr=mysql_fetch_array($result); if($upswd!=$arr['upswd']) return 1; else if ($arr['ustat']==0) return 2; else return 5; }}?>[/Code]Here sessions aren't working. I have my register_globals set to off, have provided a valid path and all other settings. So any idea what the problem is???? Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/ Share on other sites More sharing options...
techiefreak05 Posted August 2, 2006 Share Posted August 2, 2006 try taking the "exit;" out.. I have a site that does the same thing, but i don't ever use exit;I could be wrong, considering Im not a pro, but I think Im right Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67561 Share on other sites More sharing options...
redarrow Posted August 2, 2006 Share Posted August 2, 2006 first thing session_start(); is lower case ok.and secondly you alredy got header problams becouse you use ob_start(); maybe its a good idear to sort that as well ok.? Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67564 Share on other sites More sharing options...
shoaibi Posted August 2, 2006 Author Share Posted August 2, 2006 Well somethings:1st that i don't think removing exit; will do a change, still i will try.And then about lowercase and uppercase, well tell you what its correct both ways SESSION_START(); and session_start() do the same thing. and then about ob_start(), well its just something i added as a precaution so that if i accidently pass any code before the session_start(), the error "headers already sent" may not occur, i also tried by removing the ob_start() but still doens't make any change, used different browsers, but all in vain... Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67576 Share on other sites More sharing options...
redarrow Posted August 2, 2006 Share Posted August 2, 2006 do a session test then test.php[code]<?php session_start();$name="my name is redarrow";$name=$_SESSION['name'];echo"<a href='test_result.php'>test me</a>";?>[/code]test_result.php[code]<?php session_start();echo $name;?>[/code] Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67578 Share on other sites More sharing options...
shoaibi Posted August 2, 2006 Author Share Posted August 2, 2006 [quote author=redarrow link=topic=102670.msg407821#msg407821 date=1154496994]do a session test then test.php[code]<?php session_start();$name="my name is redarrow";$name=$_SESSION['name'];echo"<a href='test_result.php'>test me</a>";?>[/code]test_result.php[code]<?php session_start();echo $name;?>[/code][/quote]Well to tell the truth i did this, on the first page its displayed crystal clear but its null on second. i even used to check it using isset() and strlen but both return false. Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67581 Share on other sites More sharing options...
redarrow Posted August 2, 2006 Share Posted August 2, 2006 sorry $name=$_SESSION['name']=$name; Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67584 Share on other sites More sharing options...
shoaibi Posted August 2, 2006 Author Share Posted August 2, 2006 [quote author=redarrow link=topic=102670.msg407831#msg407831 date=1154497571]sorry $name=$_SESSION['name']=$name;[/quote]nope, i knew that you meant it that way......its just as i said, that name is asked would be display on the first page but on the second its null. Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67587 Share on other sites More sharing options...
redarrow Posted August 2, 2006 Share Posted August 2, 2006 [code]test_result.php<?php session_start();echo $name;?>test.php<?php session_start();$name="my name is redarrow";$name=$_SESSION['name']=$name;echo"<a href='test_result.php'>test me</a>";?>[/code] Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67589 Share on other sites More sharing options...
redarrow Posted August 2, 2006 Share Posted August 2, 2006 on the first page should only get the link Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67590 Share on other sites More sharing options...
redarrow Posted August 2, 2006 Share Posted August 2, 2006 your session must be off in the php.ini then thats all i can think off. Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67592 Share on other sites More sharing options...
shoaibi Posted August 2, 2006 Author Share Posted August 2, 2006 [quote author=redarrow link=topic=102670.msg407836#msg407836 date=1154497713][code]test_result.php<?php session_start();echo $name;?>test.php<?php session_start();$name="my name is redarrow";$name=$_SESSION['name']=$name;echo"<a href='test_result.php'>test me</a>";?>First that read the comments [/code][/quote]In the first code segment i.e. test_results, $name? shouldn't it be $_SESSION['name'] as $name isn't transferred, only thing lives is sessionSecondly i said that if we echo out the name in test, its displayed but not in the test_result (even by using $_SESSION['name'] Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67593 Share on other sites More sharing options...
redarrow Posted August 2, 2006 Share Posted August 2, 2006 every page got to have the <? session_start(); on it.where the name form the form name=""<INPUT TYPE="SUBMIT" VALUE="LOGIN">PHP_SELF// get rid off it use the proper way or no way. Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67602 Share on other sites More sharing options...
shoaibi Posted August 2, 2006 Author Share Posted August 2, 2006 [quote author=redarrow link=topic=102670.msg407850#msg407850 date=1154499915]every page got to have the <? session_start(); on it.[/quote]as you can see the code segments that i attached in the first post do have that, don't they? Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67603 Share on other sites More sharing options...
redarrow Posted August 2, 2006 Share Posted August 2, 2006 main has not got it. Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67604 Share on other sites More sharing options...
shoaibi Posted August 2, 2006 Author Share Posted August 2, 2006 [quote author=redarrow link=topic=102670.msg407852#msg407852 date=1154500267]main has not got it.[/quote]main has included the inc.php thus it also have got it. and evne if i write, nothing much happens as the code as soon as it read the inc.php it gets redirected to the login page as there isn't any session that exists while inc.php Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67605 Share on other sites More sharing options...
redarrow Posted August 2, 2006 Share Posted August 2, 2006 what in these thenrequire("inc.php");include_once "./cmndb.php";include_once "./pm.php";somethink must be dragging it down. Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67606 Share on other sites More sharing options...
shoaibi Posted August 2, 2006 Author Share Posted August 2, 2006 [quote author=redarrow link=topic=102670.msg407854#msg407854 date=1154500446]what in these thenrequire("inc.php");include_once "./cmndb.php";include_once "./pm.php";somethink must be dragging it down.[/quote]cmndb is a file as the name points common database, it gives connects to database for the profile information retrieval, and pm.php is a file containg function to read pm, delete, compose and etc... nothing much, even tried deleting these files or commenting these lines of code, Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67607 Share on other sites More sharing options...
redarrow Posted August 2, 2006 Share Posted August 2, 2006 very anoying and i am sitting here. Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67608 Share on other sites More sharing options...
redarrow Posted August 2, 2006 Share Posted August 2, 2006 what about using POST['varable_names'];what instead of useing the session['what_ever']=$whatevermaybe you should use session_register($whatever); then $_POST['what_ever'];i am stomped. Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67612 Share on other sites More sharing options...
shoaibi Posted August 2, 2006 Author Share Posted August 2, 2006 [quote author=redarrow link=topic=102670.msg407861#msg407861 date=1154500935]what about using POST['varable_names'];[/quote]sorry redarrow but if i had to come back to the POST and why did i used sessions, the only thing i wanted was that more secure, more reliable. and also easy, POST won't be easy as i don't thing except then the form you cna use POST to transfer information from one place to other. Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67618 Share on other sites More sharing options...
mastermike707 Posted August 2, 2006 Share Posted August 2, 2006 [quote]//login.phpob_start();SESSOIN_START();[/quote]I think the misspelling of SESSION_START() might have something to do with it. Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67625 Share on other sites More sharing options...
shoaibi Posted August 2, 2006 Author Share Posted August 2, 2006 [quote author=mastermike707 link=topic=102670.msg407874#msg407874 date=1154501497][quote]//login.phpob_start();SESSOIN_START();[/quote]I think the misspelling of SESSION_START() might have something to do with it.[/quote]That's the problem you found here, but in the actuall code its not.... ;) Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67627 Share on other sites More sharing options...
mastermike707 Posted August 2, 2006 Share Posted August 2, 2006 dang, ok figured u copied and pasted so thats why I said it. Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67628 Share on other sites More sharing options...
mastermike707 Posted August 2, 2006 Share Posted August 2, 2006 Maybe try clearing ur cookies?Look at the settings in php info for sessions. Link to comment https://forums.phpfreaks.com/topic/16288-sessions-problem/#findComment-67629 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.