phpweb-applicationsexpression-web

PHP not working with Expression Web 3


I'm starting to try to learn PHP while using Expression Web 3. I set up PHP runtime and configured the ini. What happens is my script doesn't do as it should.

My page looks like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="en-us" http-equiv="Content-Language" />
<title>Sports</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link href="master.css" rel="stylesheet" type="text/css" />
<style type="text/css">
</style>
</head>

<body>

<div id="masthead">
</div>
<div id="top_nav">
    <ul>
        <li>Sports </li>
        <li>Clubs</li>
        <li><a href="default.html">Cloud</a></li>
    </ul>
</div>
<div id="container">
    <div id="left_col">
    </div>
    <div id="page_content">
    </div>
</div>
<div id="footer">
    <form method="post">
    </form>
</div>
<form action="action.php" method="post">
 <p>Your name: <input type="text" name="name" /></p>
 <p>Your age: <input type="text" name="age" /></p>
 <p><input type="submit" /></p>
</form>
</body>

</html>

Then my PHP file looks like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>action</title>
</head>

<body>
Hi <?php echo htmlspecialchars($_POST['name']); ?>.
You are <?php echo (int)$_POST['age']; ?> years old. 
</body>

</html>

What should happen is for example if I type John as name and 50 as age, it should output Hi John, you are 50 years old. But instead it says (with Firefox) : Hi you are years old in Internet Explorer 8, it just outputs the whole php script. I'm not sure where I went wrong.

Thanks


Solution

  • Either you are not running these files from a PHP enabled webserver or the webserver is not configured to serve the used file extension as PHP. How to install and configure a webserver is best asked on ServerFault.com. Have a look at XAMP or Zend Server CE.