GetGalax
GetGalax

Reputation: 149

Multiple passwords for simple password protected page

I have a super simple page that uses a PHP password script to allow users access. It works like a charm, but I need to add a second password for another user. Does anyone know how to solve this?

Thank you!

/A

PHP:

<?php 

// Define your password 
$password = "xxx"; 

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

?> 

HTML:

<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> 
    <p>Enter Password</p><br>
<input type="password" name="txtPassword" style="width: 400px;">
</form>

Upvotes: 1

Views: 2333

Answers (1)

t3chguy
t3chguy

Reputation: 1018

$passwords = array('xxx', 'zzz', 'yyy');

if (!in_array($_POST['txtPassword'], $passwords, true)) {

}

Upvotes: 1

Related Questions