GrizzlyBear Posted July 17, 2008 Share Posted July 17, 2008 Hey Guys Im having a bit of trouble with the IF statement at the beginning of this script. For some reason, it jumps to the last else statement of the script. Thanks <?php if($_GET == register) { echo "<html> <head> <title>Register a Username</title> </head> <body> <center> <form action=\"index.php?page=registering\" method=\"post\"> <input type=\"text\" name=\"username\" value=\"type your name here\"></br> <input type=\"password\" name=\"pass1\" value=\"type your pass\"></br> <input type=\"submit\" value=\"register\"> </form> Lets check how it works!! </body> </html>"; } elseif($_GET == registering) { $username = "users/$_POST[username].php"; if(file_exists($username)) { echo "the username you chose already exists"; } else { $user=fopen("users/$_POST[username].php", "a"); fwrite($user, "<?php \$pass = '$_POST[pass]; ?>"); fclose($user); echo "you're registered, you can now login!"; } } elseif($_GET == login) { echo "<html> <head> <title>Login</title> </head> <body> <center> <form action=\"index.php?page=logging_in\" method=\"post\"> <input type=\"text\" name=\"username\" value=\"you're username here\"></br> <input type=\"pass\" name=\"pass\" value=\"you're pass here\"></br> <input type=\"submit\" value=\"login!\"> </form> Lets check how it works!! </body> </html>"; } elseif($_GET == logging_in) { $username = "users/$_POST[username].php"; if(file_exists($username)) { include($username); if($pass == $_POST['pass']) { echo "you're logged in!"; } else { echo "wrong password!"; } } else { echo "wrong username!"; } } else { echo " The page your are looking for does not exist"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/115219-loginregister-script/ Share on other sites More sharing options...
DeanWhitehouse Posted July 17, 2008 Share Posted July 17, 2008 all the gets should be $_GET['page'] Quote Link to comment https://forums.phpfreaks.com/topic/115219-loginregister-script/#findComment-592403 Share on other sites More sharing options...
unkwntech Posted July 17, 2008 Share Posted July 17, 2008 And if($_GET == register) { should be if($_GET['page'] == 'register'){ Unless register is a literal... Quote Link to comment https://forums.phpfreaks.com/topic/115219-loginregister-script/#findComment-592413 Share on other sites More sharing options...
GrizzlyBear Posted July 17, 2008 Author Share Posted July 17, 2008 Hey Guys, thanks for the help hey, but unfortunately its still not working. If is put the command as: if($_GET != register) { it brings up the register page. Any idea will be much appreciated. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/115219-loginregister-script/#findComment-592540 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.