Multiple Values in Validation

Dear Forum,

I am attempting to create a very simple login page which validates against a list of phrases. In other words, multiple users will have different phrases and when they enter any one of those phrases into a single field form they will be allowed into the page.

I have the following code so far:

Not sure what to do. For this line:

if ($_POST[‘entryphrase’] == ‘enter’) {

I would simply like to pass it to multiple values, like this:

if ($_POST[‘entryphrase’] == ‘enter’, ‘goin’, ‘entrezvous’, ‘opensesame’) {

This simple listing doesn’t work, of course, I’m just trying to illustrated that I would like the form to validate against a list.

I have no idea how to do this. I’ve read a bit about arrays - it seems as if some people suggest this - but it seems so obtuse to me in a way, and I haven’t found any clear documentation that illustrates this simple point.

Any help would be wonderful!

-stumped in NorCal

if (in_array($_POST[‘entryphrase’], array(‘enter’, ‘goin’, ‘entrezvous’, ‘opensesame’))) {
// condition is true

What a wonderful reply, M@tt. Thank you!

Works perfect. It’s surprising how hard it is to find such a straightforward answer like this by searching. I was looking for over an hour and I kept running into a ton of solutions to complex problems, but couldn’t get to the nitty gritty on this simple on.

Thanks again!

Sponsor our Newsletter | Privacy Policy | Terms of Service