Jump to content

Recommended Posts

How could I make a form, that when a user type's in a certain word or phrase it executes some code. example

 

<?php
$word = "correct";

if ( $word == form input ) {
echo "The right word was entered in the form";
}
else
if( $word != form input ) {
echo "The right word was not entered in the form";
}
?>

 

So, all I want to do, is have a Text box, a user enters a set word, in this example the word is "correct", and if they enter that word it displays the message in the if statement, and if the right word isn't entered it displays the alternative message. in the if statements where I have put the words "form input" what would I put instead so the statements are working with the form?

 

Regards ACE

Link to comment
https://forums.phpfreaks.com/topic/54394-solved-form-that-accepts-certain-words/
Share on other sites

<?php
$word = "correct";

if ( $word == form input ) {
echo "The right word was entered in the form";
}
else
if( $word != form input ) {
echo "The right word was not entered in the form";
}
?>

 

Try this:

 

<?php
$word = "correct";
$word1 = $_POST['word1'];

if($word == $word1)
{
echo "The right word was entered in the form";
}
else
{
echo "The right word was not entered in the form";
}
?>

 

I think it will help.

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.