Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.