I thought I’d take a shot at this. I highly doubt it’s possible since PHP is a server-side language. But I’ve got a login form that submits through an AJAX call, and sends back errors to a div above the login form if the user submits bad password, etc. If the user logins in successfully, I display a control panel toolbar in the div above the form, however, the form remains.
Is there a way to remove that login form with PHP? Here’s the php code
if(mysql_num_rows($result_set) == 1) {
$found_user = mysql_fetch_array($result_set);
$_SESSION['user_id'] = $found_user['user_id'];
$_SESSION['username'] = $found_user['username'];
include('includes/admTools.php'); // here's where I include the toolbar
}
else {
if($username == "" || $password == "") {
$message = "<span class=\"message\">" . "<img src=\"/images/icon_warning.gif\" height=\"16\" width=\"16\" alt=\"Warning\" />" . "Please enter your username AND password</span>";
echo $message;
}
else {
if(!isset($found_user)) {
$message = "<span class=\"message\">" . "<img src=\"/images/icon_warning.gif\" height=\"16\" width=\"16\" alt=\"Warning\" />" . "Username/password combination incorrect. Please make sure your caps lock key is off and try again.</span>";
}
echo $message;
}
}
if(isset($_GET['logout']) && $_GET['logout'] == 1) {
$message = "<span class=\"message\">You are now logged out</span>";
}