dezkit Posted February 26, 2008 Share Posted February 26, 2008 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 } ?> Quote Link to comment https://forums.phpfreaks.com/topic/93213-php-password/ Share on other sites More sharing options...
Lamez Posted February 26, 2008 Share Posted February 26, 2008 you might wanna look into MySQL databases Quote Link to comment https://forums.phpfreaks.com/topic/93213-php-password/#findComment-477530 Share on other sites More sharing options...
networkthis Posted February 26, 2008 Share Posted February 26, 2008 You can also store them in a .txt file using md5 encoding for the password Quote Link to comment https://forums.phpfreaks.com/topic/93213-php-password/#findComment-477532 Share on other sites More sharing options...
Lamez Posted February 26, 2008 Share Posted February 26, 2008 or an array Quote Link to comment https://forums.phpfreaks.com/topic/93213-php-password/#findComment-477534 Share on other sites More sharing options...
jedney Posted February 26, 2008 Share Posted February 26, 2008 I would use a MySQL database to store and have this information. Quote Link to comment https://forums.phpfreaks.com/topic/93213-php-password/#findComment-477540 Share on other sites More sharing options...
corbin Posted February 27, 2008 Share Posted February 27, 2008 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! } ?> Quote Link to comment https://forums.phpfreaks.com/topic/93213-php-password/#findComment-477582 Share on other sites More sharing options...
dezkit Posted February 27, 2008 Author Share Posted February 27, 2008 hi, hey, or whad up corbin, thanks for the code man Quote Link to comment https://forums.phpfreaks.com/topic/93213-php-password/#findComment-477612 Share on other sites More sharing options...
corbin Posted February 27, 2008 Share Posted February 27, 2008 No problem. I seriously wonder that. It's always "hello world". Who even says hello anymore? lol Quote Link to comment https://forums.phpfreaks.com/topic/93213-php-password/#findComment-477616 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.