thunderbox Posted July 1, 2007 Share Posted July 1, 2007 hey, i have a signup and login form. i need them to dissapear when they are submitted. i know that i can use a header redirect however i am not sure on how to implement this. the login form is on my main page. and its running a confirmation message through an echo statement. the echo statement shows up. but the login form does not go away. so my question. how cna i get the form to go away. and how could i do it through an echo statement (i have heard you can do it this way ) Quote Link to comment https://forums.phpfreaks.com/topic/57908-solved-getting-login-form-to-dissapear/ Share on other sites More sharing options...
pocobueno1388 Posted July 1, 2007 Share Posted July 1, 2007 You can simply exit the script with: exit; Could you post your code? That way we can directly show you how to do it. Quote Link to comment https://forums.phpfreaks.com/topic/57908-solved-getting-login-form-to-dissapear/#findComment-286960 Share on other sites More sharing options...
MadTechie Posted July 1, 2007 Share Posted July 1, 2007 can we see some code.. its kinda hard to work without it! as a guess i would say a javascript would do it!.. Quote Link to comment https://forums.phpfreaks.com/topic/57908-solved-getting-login-form-to-dissapear/#findComment-286961 Share on other sites More sharing options...
Lytheum Posted July 1, 2007 Share Posted July 1, 2007 If for instance your login form saves a session variable such as 'username' you could always do this: <?php $username = $_SESSION['username']; if !($username){ //display login form }else{ //display main page } ?> That's provided you want error checking. If you just want them to disappear when the form is submitted no matter if they have a wrong password or such you could: <?php if ($_POST['submit']){ //display main page }else{ //display login form } ?> Quote Link to comment https://forums.phpfreaks.com/topic/57908-solved-getting-login-form-to-dissapear/#findComment-286963 Share on other sites More sharing options...
thunderbox Posted July 1, 2007 Author Share Posted July 1, 2007 here is my code. where would i put the exit; ? $email = mysql_real_escape_string($_POST['email']); $password = mysql_real_escape_string($_POST['password']); if ($password == '') {echo 'The Password Field Was Not Filled In';} if ($email == '') {echo 'The email Field was not filled in';} $password = md5($password); $login = mysql_query("SELECT * FROM users WHERE email='$email' and password='$password'"); $login2 = mysql_num_rows($login); if ($login2 > 0) { $userid = mysql_query("SELECT userid FROM users WHERE email='$email'"); // Write Session Data $_SESSION['userid'] = $userid; $_SESSION['auth'] = true; echo 'login sucessful!'; } Quote Link to comment https://forums.phpfreaks.com/topic/57908-solved-getting-login-form-to-dissapear/#findComment-286966 Share on other sites More sharing options...
MadTechie Posted July 1, 2007 Share Posted July 1, 2007 try <?php // Write Session Data $_SESSION['userid'] = $userid; $_SESSION['auth'] = true; //echo 'login sucessful!'; <-- commented out header('Location: userspage.php'); //<--Added ?> may work but without a complete understanding of what your doing its a guess! Quote Link to comment https://forums.phpfreaks.com/topic/57908-solved-getting-login-form-to-dissapear/#findComment-286974 Share on other sites More sharing options...
thunderbox Posted July 1, 2007 Author Share Posted July 1, 2007 i think i solved it. using an if statement i managed to change it. and it seems to work so far. so ill mark this thread as solved. Quote Link to comment https://forums.phpfreaks.com/topic/57908-solved-getting-login-form-to-dissapear/#findComment-286982 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.