0

I have two files, testpage.html and testpage.php in the same folder.

This is testpage.html

<!DOCTYPE HTML>
<html>
<body>

<form action="testpage.php" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>

</body>
</html>

This is testpage.php

<html> 
<body>

Welcome <?php echo $_POST["name"]; ?><br> 
Your email address is: <?php echo $_POST["email"]; ?><br> 

</body>
</html>

The form seems to work okay but when I hit submit nothing shows up on the next page. no matter what I enter int he form, it always reads "Welcome" "Your email address is:" with nothing entered after that like its supposed to.

Do I have something configured incorrectly? Am I using the wrong browser (firefox)?

Thanks!

Indigo
  • 962
  • 1
  • 8
  • 23
  • When you view the page source, what specifically do you see? – David Jan 12 '16 at 18:50
  • *"Am I using the wrong browser (firefox)?"* - Smells like `file:///C:/file.xxx` instead of a host. – Funk Forty Niner Jan 12 '16 at 18:50
  • possible duplicate of http://stackoverflow.com/questions/5121495/php-code-is-not-being-executed-i-can-see-it-on-source-code-of-page – Funk Forty Niner Jan 12 '16 at 18:50
  • Does it work if you add this attribute `enctype="multipart/form-data"` to your
    at testpage.php?
    – Eduardo Escobar Jan 12 '16 at 18:51
  • @Fred-ii- if that were the case, he would see PHP code. I think it might have something to do with invalid HTML? No idea, but it's always a good idea to AUTO-CLOSE TAGS `` – Alex Jan 12 '16 at 18:52
  • 3
    @AlexanderMP I'm thinking OP isn't telling us the full story and accessing as `file:///C:/file.xxx` instead of `http://host/file.xxx`. Least, that's my take on it, or their server's not properly configured. This *"Do I have something configured incorrectly? Am I using the wrong browser (firefox)?"* is a sign and a very unclear one at that. – Funk Forty Niner Jan 12 '16 at 18:53
  • Do you have Xampp activated or any virtual server to test your PHP? Or did you tested it online? people are right, you're probably accessing it directly in your folder but it won't work this way – Yann Chabot Jan 12 '16 at 18:56
  • I am accessing it via file:///C:/... should I be accessing it some other way instead? – Indigo Jan 12 '16 at 18:56
  • Yes, you should be accessing it via a web server that is running PHP. – Patrick Q Jan 12 '16 at 18:57
  • I don't think I have Xampp or any virtual server set up... I'll look into that, any tips on where to start? – Indigo Jan 12 '16 at 18:57
  • seems to be working just fine http://codepad.viper-7.com/wkFKTK – Alex Jan 12 '16 at 19:00

1 Answers1

4

"I am accessing it via file:///C:/... should I be accessing it some other way instead?"

  • Just as I thought.

There you go. A web browser will not parse PHP directives that way.

It must be accessed as http://localhost/yourfile.xxx

Plus, a webserver and PHP need to be installed in order to parse PHP directives.

"I don't think I have Xampp or any virtual server set up... I'll look into that, any tips on where to start?"

You need to install one. Here are a few links to get you started and depending on the platform you are using.

Pick your flavour.

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141