Reputation: 559
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.
Upvotes: 0
Views: 373
Reputation: 7362
Restart Apache or whatever your webserver may be.
sudo service apache2 restart
in Ubuntu, or use the XAMPP control panel.
Then try again.
Upvotes: 0
Reputation: 2898
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.
Upvotes: 1