Jump to content

Why this simple script won't work?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
Indentatus

Indentatus

    Newbie

  • Members
  • Pip
  • 1 posts
I'm learning PHP from homeandlearn.co.uk, and I'm trying to just have the user enter a username into the text box and press submit, to display if i'm a member of the site or not.

As you can see, if I type "letmein" it should say "Welcome back, friend!"

But NOTHING at all happens, and on the website the exact code they give is this, and it doesn't work :S So I'm trying to figure out for myself what's not right!

Can you guys help please:)

<?php

if(isset($_POST["Submit"]))

    {

        $username = $_POST["username"];


            if ($username == "letmein")

                {

                    print("Welcome back, friend!");

                }

                else

                    {

                        print("You are not a member of this site.");

                    }

    }

?>


#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
That code should work fine, assuming you have name="Submit" in the form submit button attributes. Can you post your HTML portion of the code?
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.