View Full Version : include code on false text input

09-02-2011, 05:26 AM
Hi guys. ;)

What I'm trying to do is have my PHP code include a file when a correct word is typed into a text box. If the wrong word is typed, I'm aiming to for it to echo an error message. Heres what I have so far (I know it's most likely very wrong, but I was hoping someone could help me out! :D)


$password = "something";

if ( $password == "something" ) {
echo "Wrong!<br />"


I have the textbox named "password", but am not sure what I should be using for the method and action tags as part of the form.

Thanks in advance!


09-02-2011, 05:48 AM
Use method="post" and action="thenameofthephpfileyoushowabove.php"

Then in that php file, change to:
$password = $_POST['password'];
...assuming your input tag name is "password".


09-02-2011, 06:39 AM
Thanks tracknut! I'll test it out now. I knew I was missing something, turned out it was the $_POST part. :D

EDIT: Works! Thanks a lot tracknut. :D