Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    psy
    psy is offline
    New Coder
    Join Date
    Jul 2011
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts

    include code on false text input

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

    PHP Code:
    <?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

  • #2
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,139
    Thanks
    7
    Thanked 257 Times in 256 Posts
    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

  • Users who have thanked tracknut for this post:

    psy (09-02-2011)

  • #3
    psy
    psy is offline
    New Coder
    Join Date
    Jul 2011
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks tracknut! I'll test it out now. I knew I was missing something, turned out it was the $_POST part.

    EDIT: Works! Thanks a lot tracknut.
    Last edited by psy; 09-02-2011 at 05:44 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •