I have a simple php pass protect page script
<?php
// Define your username and password
$username = "smithalan2";
$password = "theteenzone";
if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password ) {
?>
but i want to have 2 usernames and 2 passwords , im not sure what code to edit though , im guessing i'd add another variable like $username2 = " ***"; or something but im not sure what i'd add on line if ($_POST['txt................etc?
Help Would be appreciated
Anyone?? this is the actual whole code
<?php
// Define your username and password
$username = "smithalan2";
$password = "theteenzone";
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><font color="white">No Staff News Yet But Check Back Soon For More Details!</font></p>
<?php
}
?>
emm *bump* anyone?????
thats one messed up script.
should be like this:
if ($_POST['txtUsername'] == $username && $_POST['txtPassword'] == $password ) {
That says if username and password are correct it will display your page. otherwise give them a login screen. maybe and error 2.
then you can double it up easy
if (($_POST['txtUsername'] == $username && $_POST['txtPassword'] == $password ) || ($_POST['txtUsername'] == $username2 && $_POST['txtPassword'] == $password2 )) {
Im glad you disabled it agaisn't url insertion. but i would take it a step further.
md5 your password to add some security on it. maybe your name to if you want. could use some other encryption as well like adding your site name in and such.
just create a php page with a simple md5 in it
<?
echo md5($_GET['a']);
?>
do a=yourpassword in url and it will give md5 of the password. put it in place of our password
then change this password part in your if statement
$txtPassword = md5($_POST['txtPassword']);
Why not just link it to SMF?
That was just a little script i was playing around on a html/php website.
How's this?
<?php
// Define your username and password
$usernames = array("username1",'username2','username3');
$passwords = array('password1','password2','password3');
$key = array_search($_POST['txtUsername'],$usernames);
if ($key === false && array_search($_POST['txtPassword'],$passwords) !=$key) {
?>
You can have as many username-password pair you wish.
Thanks ! , i wasnt actually planning on using it on a template at the moment but im getting a idea of something i'll be able to use it in!