...

View Full Version : include code on false text input



psy
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)


<?php

$password = "something";

if ( $password == "something" ) {
include("correct.php");
}
else
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!

-psy

tracknut
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".

Dave

psy
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum