0

I-m writing a simple form in HTML that submits the user name and age, then opens a .php page and prints them.

This is the code:

main.html

<form action="Test.php" method="post">
 Name: <input type="text" name="fname" />
 Age: <input type="text" name="age" />
 <input type="submit" />
</form>

Test.php

Welcome <?php echo $_POST["fname"]; ?>!<br />
You are <?php echo $_POST["age"]; ?> years old.

Тhe problem is, when I open the main.html, enter some values and press Submit, it doesnt show me the Test.php page, instead it downloads it.

Аny suggestions?

Thanks.

Nikola K.
7,15313 gold badges33 silver badges39 bronze badges
asked Jul 4, 2012 at 20:44
8
  • 2
    Does the server support php at all? Commented Jul 4, 2012 at 20:46
  • 2
    Php not configured properly for your server Commented Jul 4, 2012 at 20:47
  • @DmitryTeplyakov, How can I configure it properly? Commented Jul 4, 2012 at 20:50
  • 2
    Are you requesting the page via localhost/127.0.0.1 or just opening the file in the browser? Commented Jul 4, 2012 at 21:01
  • Try adding a test PHP script to your web server dir, and make sure PHP is actually installed/enabled. <?php phpinfo(); ?> - user1027562 Commented Jul 4, 2012 at 21:02

2 Answers 2

1

Check your server is running. Check you request page properly (http://localhost/main.html or over your virtual host)

XAMPP should be configure server properly. Most common things for php work in httpd.conf are:

LoadModule php5_module modules/libphp5.so # or necessary .dll for windows
AddType application/x-httpd-php .php

Restart apache and try again. Try to directly request Test.php, you should see some warnings if all is ok.

answered Jul 4, 2012 at 21:04
Sign up to request clarification or add additional context in comments.

Comments

0

Restart Apache or whatever your webserver may be.

sudo service apache2 restart in Ubuntu, or use the XAMPP control panel.

Then try again.

nhahtdh
56.9k15 gold badges131 silver badges164 bronze badges
answered Jul 4, 2012 at 20:57

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.