Jump to content

[SOLVED] getting login form to dissapear


thunderbox

Recommended Posts

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 )

Link to comment
https://forums.phpfreaks.com/topic/57908-solved-getting-login-form-to-dissapear/
Share on other sites

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
}
?>

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!';
}

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.