The task, a rather simple one. In one .HTML page is the HTML script whose task is to 'collect imput' and pass 'this data' (given to variable names) onto another .php page, then display the variables.
This simple .HTML page is -
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<form action="processorder.php" method="post">
<table border="0">
<tr bcolor="#cccccc">
<td with="150">Item</td>
<td with="5">Quantity</td>
</tr>
<tr>
<td>Tires</td>
<td align="center"><input type="text" name="tireqty" size="3" maxlength="3" />
</td>
</tr>
<tr>
<td>Oil</td>
<td align="center"><input type="text" name="oilqty" size="3" maxlength="3" />
</tr>
<tr>
<td>Spark Plugs</td>
<td align="center"><input type="text" name="sparkqty" size="3" maxlength="3" />
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Submit Order" />
</td>
</tr>
</table>
</form>
</body>
The input is collected and the call
<form action="processorder.php" method="post">
fails to 'load the .php file into the browser but will OPEN this file onto the clipboard.
The simple processorder.php file is
<?php
// create short variable names
$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$sparkqty = $_POST['sparkqty'];
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
echo "<p>Order processed at ";
echo date('H:i, jS F Y');
echo "</p>";
echo '<p>Your order is as follows:</p>';
echo $tireqty.'tires<br />';
echo $oilqty.';bottles of oil<br />';
echo $sparkqty.';spark plugs<br />';
?>
</body>
</html>
Nothing too complicated, just a simple exercise in passing variables around. So, the question remains as to why the call does not load the .php file but instead opens the .php file and the variables collected in one page are not passed onto another page.
Each page loaded onto the browser does load seperately but of course, the variables are not then collected in one page and passed onto the other page which is the principale objective.
If the line on the orderform.html page which is
<form action="processorder.php" method="post">
is then edited to be
<form action="processorder.html" method="post">
then the page is loaced onto the browser and not opened to the clipboard. The other change to this .html file is the tag
All this is happening inside the Rapid PHP 2007 editor.
PHP is 'present' in the files and configured with the Rapid 2007 editor.
One question is about the IE browser and how the browser detects/decides not to loa开发者_C百科d the file, execute the PHP parts or what the problem is by not loading the file but opening the file to the clipboard.
Your PHP files are probably delivered as text/plain by your server (or you don't use any server, or your server doesn't support PHP)
It sounds like you haven't got PHP correctly installed. First create a simple php page with just:
<?php
phpinfo();
?>
If this doesn't does the same, and you just see the source code then you need to check your PHP stack setup.
A good place to get started is by downloading a complete stack such as EasyPHP:
http://www.easyphp.org/
Then following the install instructions.
http://www.easyphp.org/introduction.php
PHP has nothing to do with Internet Explorer and vice-versa, but considering that you've tagged your question with internet-explorer
, I guess you're not having that issue with Firefox, Chrome, Opera, etc. ... and that would mean it's nothing related to PHP.
In that case - you actually have a whole bunch of problems:
- Your HTML code is not valid according to W3C standards.
- You have extra output before the actual HTML code starts.
- IE has a long history of web standards incompatibility and on top of that, it's pretty bad at guessing content types too. So even if you were conforming to the standards - you could still have the same problem, although I doubt you're using IE 6, so that's probably not the case. But I guess it's best explained in here.
So ... what you could do to fix it:
- Remove the white-spaces(new lines count too!) preceeding the
<html>
tag. - Send a content-type header with PHP(it's still not related to it - you'd have the same problem if you were using e.g. Perl or Ruby).
- Removing the
xmlns
attribute could probably work ... but only in IE 6, and you'd still have to remove the white-spaces. - Include a DOCTYPE declaration - this would make sure that the browser knows what type of document it's trying to render, instead of leaving it to guess in "dumb mode".
精彩评论