Jump to content

[SOLVED] form that accepts certain words


MasterACE14

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.

Archived

This topic is now archived and is closed to further replies.

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