Racc Posted February 4, 2007 Share Posted February 4, 2007 Basically I've known php/mysql for a couple days. After tons of reading and creating pages and a site as I go along, i've gotten stuck. Basically this is my nav include. I had threw logout in there and tried doing all sorts of nonsense. =P <div id="nav"> <a href="?s=main" title="main" id="main"><span>Main</span></a> ~ <a href="?s=login" title="login" id="login"><span>Login</span></a> ~ <a href="?s=register" title="register" id="register"><span>Register</span></a> ~ <a href="?s=blog" title="blog" id="blog"><span>Blog</span></a> ~ <a href="?s=downloads" title="downloads" id="downloads"><span>Downloads</span></a> ~ <a href="?s=tutorials" title="tutorials" id="tutorials"><span>Tutorials</span></a> ~ <a href="?s=author" title="author" id="author"><span>Author</span></a> ~ <a href="?s=links" title="links" id="links"><span>Links</span></a> </div> This is my index coding. <?php include("include/session.php"); if (isset($_GET['s'])) $s = $_GET['s']; else $s = "main"; include("includes.php"); ?> <div id="content"> <?php if ($s == "main") { include("content/main.php"); } else if ($s == "login") { include("content/login.php"); } else if ($s == "register") { include("register.php"); } else if ($s == "blog") { include("content/blog.php"); } else if ($s == "downloads") { include("content/downloads.php"); } else if ($s == "tutorials") { include("content/tutorials.php"); } else if ($s == "author") { include("content/author.php"); } else if ($s == "links") { include("content/links.php"); } else { echo "<p class=\"error\">The section $s does not exist!</p>\n"; } ?> <?php include("footer.php"); ?> </div> </body> When Logged in i'd like it to say "logout" and when i'm logged out "log in". Though i'd like it in the navigation. This is what it looks like as of now, I still have alot of coding to do. (I left the "log in" link there so you will get a feel for what i'm talking about and where I'm trying to put the link.) Thanks! Let me know. ??? Link to comment https://forums.phpfreaks.com/topic/37012-solved-sessions/ Share on other sites More sharing options...
JasonLewis Posted February 4, 2007 Share Posted February 4, 2007 your navigation would have to look like this. (note you may need to change the name of your session. <div id="nav"> <a href="?s=main" title="main" id="main"><span>Main</span></a> ~ <?php if(!isset($_SESSION['user'])){ ?> <a href="?s=login" title="login" id="login"><span>Login</span></a> ~ <?php }else{ ?> <a href="?s=logout" title="logout" id="logout"><span>Logout</span></a> ~ <?php } ?> <a href="?s=register" title="register" id="register"><span>Register</span></a> ~ <a href="?s=blog" title="blog" id="blog"><span>Blog</span></a> ~ <a href="?s=downloads" title="downloads" id="downloads"><span>Downloads</span></a> ~ <a href="?s=tutorials" title="tutorials" id="tutorials"><span>Tutorials</span></a> ~ <a href="?s=author" title="author" id="author"><span>Author</span></a> ~ <a href="?s=links" title="links" id="links"><span>Links</span></a> </div> i hope you understand. Link to comment https://forums.phpfreaks.com/topic/37012-solved-sessions/#findComment-176700 Share on other sites More sharing options...
Racc Posted February 4, 2007 Author Share Posted February 4, 2007 hmm. When I try logging in I get this. Fatal error: Call to a member function login() on a non-object in C:\xampp\htdocs\process.php on line 60 Then I go to line 60.. $retval = $session->login($_POST['user'], $_POST['pass'], isset($_POST['remember'])); I'm still VERY VERY new, i'd apprieate even more help if it's not too much of a bother. Thanks for the quick response. Link to comment https://forums.phpfreaks.com/topic/37012-solved-sessions/#findComment-176707 Share on other sites More sharing options...
JasonLewis Posted February 4, 2007 Share Posted February 4, 2007 well its saying that the function login doesnt exist in the class session. check. Link to comment https://forums.phpfreaks.com/topic/37012-solved-sessions/#findComment-176745 Share on other sites More sharing options...
Racc Posted February 4, 2007 Author Share Posted February 4, 2007 Quote well its saying that the function login doesnt exist in the class session. check. The thing is... I figured out why i'm having such a hell of a time. I include session.php in index.php. Then I'd had it included in process.php (the logout) aswell. This is where it fucks up. I run the process.php (by clicking on logout), then "blah blah errors" which means that it was included twice and you can't do that. So I clear my cookies and cache, delete the inclusion from process.php. I then go back to the site and click login, woo! looks like smooth sailing. I then try to login and get this error. (such as last time) Fatal error: Call to a member function login() on a non-object in C:\xampp\htdocs\process.php on line 60 Thanks for the reply last time. =D *chronically presses f5* Link to comment https://forums.phpfreaks.com/topic/37012-solved-sessions/#findComment-176763 Share on other sites More sharing options...
JasonLewis Posted February 5, 2007 Share Posted February 5, 2007 please mind your language. as i said before, does the function exist? what is line 60!? Link to comment https://forums.phpfreaks.com/topic/37012-solved-sessions/#findComment-177223 Share on other sites More sharing options...
Racc Posted February 5, 2007 Author Share Posted February 5, 2007 Quote hmm. When I try logging in I get this. Fatal error: Call to a member function login() on a non-object in C:\xampp\htdocs\process.php on line 60 Then I go to line 60.. $retval = $session->login($_POST['user'], $_POST['pass'], isset($_POST['remember'])); And pardon my language. You know, I could be a jerk because you were rude for NO reason. "What's in line 60!?" And yes it exists. Link to comment https://forums.phpfreaks.com/topic/37012-solved-sessions/#findComment-177224 Share on other sites More sharing options...
JasonLewis Posted February 5, 2007 Share Posted February 5, 2007 eek, sorry i didnt see the post above. anyways. so $session is your class, could you please search the class for a function called login. or just attach the file which contains the class $session. thanks. Link to comment https://forums.phpfreaks.com/topic/37012-solved-sessions/#findComment-177232 Share on other sites More sharing options...
Racc Posted February 5, 2007 Author Share Posted February 5, 2007 Quote eek, sorry i didnt see the post above. anyways. so $session is your class, could you please search the class for a function called login. or just attach the file which contains the class $session. thanks. It's okay, I just got a little frustrated when I saw "Hey idiot I told you!" I switched a few things around, I now have new errors. =| I made login.php, process.php, and register.php all include "include("include/session.php");" rather then including it in the index.php. I now get this error when I click "login.php" and when I click "Register.php". Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\index.php:2) in C:\xampp\htdocs\include\session.php on line 46 And I will include the index.php line 2 ~ 10ish. and Will include session.php line 46. 46: session_start(); //Tell PHP to start the session and 2: <?php 3: if (isset($_GET['s'])) 4: $s = $_GET['s']; 5: else 6: $s = "main"; 7: include("container.php"); 8: include("header.php"); 9: include("nav.php"); 10: ?> Link to comment https://forums.phpfreaks.com/topic/37012-solved-sessions/#findComment-177241 Share on other sites More sharing options...
JasonLewis Posted February 5, 2007 Share Posted February 5, 2007 session_start() must be at the very top of your page, right below <?php no whitespaces. and sorry if this is stupid and you answered it in that post but whats this code: 2: <?php 3: if (isset($_GET['s'])) 4: $s = $_GET['s']; 5: else 6: $s = "main"; 7: include("container.php"); 8: include("header.php"); 9: include("nav.php"); 10: ?> Link to comment https://forums.phpfreaks.com/topic/37012-solved-sessions/#findComment-177244 Share on other sites More sharing options...
Racc Posted February 5, 2007 Author Share Posted February 5, 2007 Quote session_start() must be at the very top of your page, right below <?php no whitespaces. and sorry if this is stupid and you answered it in that post but whats this code: 2: <?php 3: if (isset($_GET['s'])) 4: $s = $_GET['s']; 5: else 6: $s = "main"; 7: include("container.php"); 8: include("header.php"); 9: include("nav.php"); 10: ?> That would be my index. line: 2 ~ 10. Or are you asking what all it does? (which is quite odd sense you seem to know what you're doing.) EDIT: almost there, I can now login, register and logout...sorta. =P The logout page gives and error but logs out anyway. Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\container.php:1) in C:\xampp\htdocs\process.php on line 82 I'm still playing aroudn with it, I'm so close. O_O Link to comment https://forums.phpfreaks.com/topic/37012-solved-sessions/#findComment-177245 Share on other sites More sharing options...
Racc Posted February 5, 2007 Author Share Posted February 5, 2007 Oddly enough I cannot edit my post anymore, the forum will not allow me to. O_O Either way, I deleted line 82, just for kicks. It worked! No error...but the redirection obviously doesn't work. I'll have to work on that. =P Thanks for all your help, as far as i'm concered you did your job helping me, i'll set this as case solved or whatever. If you have any suggestions on the other part just send me a message or whatever. EDIT: (2:34:16 AM) Racc: =P (2:36:01 AM) Racc: I LOVE YOU! Thanks for the help, much apprietiated Link to comment https://forums.phpfreaks.com/topic/37012-solved-sessions/#findComment-177246 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.