MasterACE14 Posted June 6, 2007 Share Posted June 6, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/54394-solved-form-that-accepts-certain-words/ Share on other sites More sharing options...
jitesh Posted June 6, 2007 Share Posted June 6, 2007 (1) Take all invalid words in javascipt Array (2) Fire Text box onchange event (3) At onchange call a javascript function which will search a word in javascript array. (4) If word found in array then make alert and return false elase do needfull. Quote Link to comment https://forums.phpfreaks.com/topic/54394-solved-form-that-accepts-certain-words/#findComment-268965 Share on other sites More sharing options...
mmarif4u Posted June 6, 2007 Share Posted June 6, 2007 <?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. Quote Link to comment https://forums.phpfreaks.com/topic/54394-solved-form-that-accepts-certain-words/#findComment-268967 Share on other sites More sharing options...
MasterACE14 Posted June 6, 2007 Author Share Posted June 6, 2007 Thankyou for the speedy replies, I've found mmarif4u to be very useful, jitesh one is abit more confusing lol. Thanks again guys Quote Link to comment https://forums.phpfreaks.com/topic/54394-solved-form-that-accepts-certain-words/#findComment-268971 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.