Jump to content

php password


dezkit

Recommended Posts

how do i make multiples?

 

 

<?php



// Define your username and password

$username = "someuser";

$password = "somepassword";



if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {



?>



<h1>Login</h1>



<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">

    <p><label for="txtUsername">Username:</label>

    <br /><input type="text" title="Enter your Username" name="txtUsername" /></p>



    <p><label for="txtpassword">Password:</label>

    <br /><input type="password" title="Enter your password" name="txtPassword" /></p>



    <p><input type="submit" name="Submit" value="Login" /></p>



</form>



<?php



}

else {



?>



<p>This is the protected page. Your private content goes here.</p>



<?php



}



?> 

Link to comment
https://forums.phpfreaks.com/topic/93213-php-password/
Share on other sites

I suggest not putting them in the script if you have a lot of them, but you could always do:

 

(this assumes usernames are never the same even with different capitalization.  Eg. Corbin = corbin)

 

<?php
$users = array(
     //user => password,
     'corbin' => 'mypass',
     'dezkit' => 'yourpass',
     'someoneelse' => 'hispass',
);

//pretend $user is a value from a form or somewhere submitted by a user.
//also pretend $pass has been submitted.

$luser = strtolower($user);

if(isset($users[$user]) && $users[$user] == $pass) {
     //correct!
}

?>

Link to comment
https://forums.phpfreaks.com/topic/93213-php-password/#findComment-477582
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.