1

I have a index.html file that have the following:

        <!DOCTYPE html>
        <html>
        <form action="email.php" method="get">
            Name: <input type="text" name="name"><br>
            E-mail: <input type="text" name="email"><br>
            <input type="submit">
        </form>
        </html>

And a email.php file with the following:

<!DOCTYPE HTML>
<html>
    <body>
       Welcome <?php echo $_GET["name"]; ?><br>
       Your email address is: <?php echo $_GET["email"]; ?>
    </body>
</html>

However I'm getting this:

Welcome 
Your email address is:

whenever I run it using Brackets and typing into the input. Both of the files are in the same folder. How come what I typed are not showing? What am I doing wrong? Currently just started learning PHP. Thanks.

7
  • What URLs are showing in the location bar? Commented Jan 1, 2015 at 8:23
  • You have to click on submit button after filling form Commented Jan 1, 2015 at 8:27
  • I did submit it.. After I submit it the url is /.../email.php?name=asdf&email=asdf The "asdf" are what I typed however it's not showing up in the browser. Commented Jan 1, 2015 at 8:31
  • Are you running a php server? For example WAMP or XAMPP ? Commented Jan 1, 2015 at 8:32
  • Hmm I'm just using brackets and using its "Live preview" feature, so I guess no? Do I need to? I thought Brackets would be enough. Commented Jan 1, 2015 at 8:38

3 Answers 3

2

Your code is correct. But you must install wampserver and copy your file(like that's name is stack) to "www" foldre in "C:\wamp\www". After, run by localhost like "localhost/stack/main.php" in browser address bar.

Sign up to request clarification or add additional context in comments.

Comments

2

To further answer this, PHP is a server-side language, so unless your editor has the ability to run PHP (and you have it set up to point to your local PHP copy), the live view feature will likely only work with client-side languages, like Javascript.

You need to install a server like XAMPP as suggested above.

Comments

1

Your question is from W3 schools same code mentioned here for demo they have server to run their page so you need server to run PHP file while running in localhost

Php is server side application so you need to have server like Wampserver Here is full tutorials installing and running PHP

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.