Passing variables from one HTML page to another.

Discuss general web development questions. Help others and get help from others.

Moderator: kfury77

Passing variables from one HTML page to another.

Postby rbbenson » Thu Apr 28, 2011 2:52 am

The task, a rather simple one. In one .HTML page is the HTML script whose task is to 'collect imput' and pass 'this data' onto another .php page.

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>Bob's Auto Parts - 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 <?pgp is changed from 'black' text to 'red' text. No clue what's up with this.

All this is happening inside the Rapid PHP 2007 editor.
rbbenson
 
Posts: 2
Joined: Wed Apr 27, 2011 12:50 am

Re: Passing variables from one HTML page to another.

Postby DevlshOne » Tue Oct 18, 2011 7:24 pm

You'll need to make sure that your PHP installation is valid and that RapidPHP's PHP setup is correct. As it sounds, your PHP installation is not correctly processing the .php scripts, opening them instead of passing them through the PHP handler.
User avatar
DevlshOne
 
Posts: 8
Joined: Wed Oct 05, 2011 5:47 pm


Return to Web Developer Talk

Who is online

Users browsing this forum: No registered users and 1 guest

cron