Logging in requiring 2 clicks, switch problem

Hello again!
This time I’m working on a simple login system, where there’s only 1 user. The problem(s) I’m encountering is that when I’ve written the right username-password combination and clicked the login button the textfields go blank and I need to press login again(this time I don’t need to enter anything in the textfields).


<?php include 'Variables/variable-loginbuttons.php'; function prelogin(){ ?>
<form method = "POST" action = 'textfieldSwitchtest.php'>
<input title = "Username"   name = "username" type = "text" /> <br>
<input title = "Password"  name = "password" type = "password"  /> <br>
<input value = 'Login' type = 'submit' name = 'login' />    <br>  
    $username = $_POST['username'];
    $password = $_POST['password'];
    if($username == "SuperAdmin123987" && $password == "IamTheBest543678"){    
        $var_int = var_export($loginbuttonsshowing, true);
        $var = "<?php\n\n\$loginbuttonsshowing = $var_int;\n\n?>";
        file_put_contents('Variables\variable-loginbuttons.php', $var);   
        echo "Wrong username and password combination.";


function prelogout(){
echo “You are logged in as SuperAdmin123987.”;

echo “You have successfully logged out.”;
$var_int = var_export($loginbuttonsshowing, true);
$var = “<?php\n\n\$loginbuttonsshowing = $var_int;\n\n?>”;
file_put_contents(‘Variables\variable-loginbuttons.php’, $var);

case 1:

case 2:





As you can see it is the switch that is causing the problem. It is loading either function and when the function is done I need to press one of the buttons to get the switch to react to the change of $loginbuttonsshowing.
How do you do make it require only one click to log in? And how do you make a button disappear?
I want to be able to log in with only 1 click of the log in button and I want to click the log out button once and then a new button that says ‘OK’ will replace it. After I’ve clicked the ‘OK’ button I’ll return to case 1, the login part.


Sponsor our Newsletter | Privacy Policy | Terms of Service