Jump to content

Compare 4 text fields and return page if correct.


tmcdonnell

Recommended Posts

Hi,

 

So i have a form with 4 text inputs (input1,input2,input3,input4).

 

When the user puts in 4 correct words, they are redirected to another page.

 

The words can be checked either via a field in a database or a variable.

Any wrong word in any of the text fields returns the user back to the page.

 

In other words: When the user clicks submit, we need to make sure all of the words are correct.

If they are not correct, nothing should happen. The user will remain on the page until they enter the correct words.

 

If the words ARE correct, they are directed to a new page with an image.

 

 

I am not sure how to approach this, I tried using if and case, however I am not sure of the combination to make all 4 fields checked before an out is given (ie, the page redirect).

 

Any help is appreciated.

 

 

 

Link to comment
Share on other sites

Really?

 

<?php
if (
	!isset($field_1)
		OR
	!isset($field_2)
		OR
	!isset($field_3)
		OR
	!isset($field_4)
)
{
// go back to your page
}

if ($field_1 != 'what it should')
{
// go back to your page
}

if ($field_2 != 'what it should')
{
// go back to your page
}

if ($field_3 != 'what it should')
{
// go back to your page
}

if ($field_4 != 'what it should')
{
// go back to your page
}

// go to the result page

?>

 

I must be missing something. It can't be as simple as I think it is.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.