kirbyweb Posted November 25, 2009 Share Posted November 25, 2009 I think this is my last question yay, then I am stopping my project until I can find graphic designers.So anyway, how would I make it so when the user logs in then it takes away the login form?I need a code or a link or something please, a little faster if possible thanks. Link to comment Share on other sites More sharing options...
norNerd Posted November 25, 2009 Share Posted November 25, 2009 <?php if(empty($_COOKIE['user'])){ ?>login page<?php } else { ?>main page<?php } ?> Hope it helps Link to comment Share on other sites More sharing options...
justsomeguy Posted November 25, 2009 Share Posted November 25, 2009 It depends on how your login form is set up, but one option would be to redirect to a different page, or refresh the same page but have code like norNerd shows that checks whether or not to show the form, or you can also use Javascript to just remove the entire form element from the DOM structure. If you did that you would need the login form to be using ajax to send the login request and get the response, and if the response indicated a successful login then you could remove the form element. Link to comment Share on other sites More sharing options...
kirbyweb Posted November 25, 2009 Author Share Posted November 25, 2009 Just in php and html please. Link to comment Share on other sites More sharing options...
justsomeguy Posted November 25, 2009 Share Posted November 25, 2009 That's one of the first two options, so after they log in either redirect them to a new page or redirect them to the same page and include code on the page to determine if you should show the form. Link to comment Share on other sites More sharing options...
kirbyweb Posted November 25, 2009 Author Share Posted November 25, 2009 How though?and how do I use nornerd's code? Link to comment Share on other sites More sharing options...
justsomeguy Posted November 25, 2009 Share Posted November 25, 2009 You redirect by sending a location header like I showed you in the other thread. The code he posted here just shows an if statement that checks for a cookie. If you're keeping track of the logged in user in the session, then you would use an if statement to check the session to see if the user is logged in, and only show the form if they are not logged in. So you would wrap your HTML form inside an if statement that checks if they're logged in before showing the form. Link to comment Share on other sites More sharing options...
kirbyweb Posted November 25, 2009 Author Share Posted November 25, 2009 ??? Link to comment Share on other sites More sharing options...
justsomeguy Posted November 25, 2009 Share Posted November 25, 2009 What exactly are you not understanding about what I wrote? Contrary to popular belief, responding with a series of punctuation is actually not helpful at all. Link to comment Share on other sites More sharing options...
kirbyweb Posted November 25, 2009 Author Share Posted November 25, 2009 Got it, I changed cookie to session. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.