Jump to content

Login/|Register Script


GrizzlyBear

Recommended Posts


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";

}

 

?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/115219-loginregister-script/
Share on other sites

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.