I'm missing a Basic PHP Concept
Posted: Fri Aug 20, 2010 5:29 pm
I think I am missing a basic concept about PHP.The code below is part of a Form within an HTML page I designed.
[text]<form method="post" action="view.php">
<td width = "10% align="middle"><input align="middle" type="submit" value= " View Cart" size = "11"/></td>
</form[/text]
This code is called by the code above:
< In the file "CartFile.txt", there are 2 records. these records, when written, were written with code like this:The only thing that was different is the $txt line.
What's happening when I execute this code, on my screen, I see a black page come up and then the routines takes me back to my sites Home page.
I have learned that when PHP wants to use data from HTML form you code something like this:where Quantity1 is the NAME of a form object.
My problem or question, how to a get the data, read via the print routine above, displayed on a Form.
To maybe give you a better idea of what I am trying to do is: I developed an Order Form that writes records to a flat-file called CartFile.txt(the code above is how it's done). On the form, I have a Submit button called "View Cart". When the user clicks the "View Cart" button, I want to display there order.
[text]<form method="post" action="view.php">
<td width = "10% align="middle"><input align="middle" type="submit" value= " View Cart" size = "11"/></td>
</form[/text]
This code is called by the code above:
<
Code: Select all
html>
<body>
<?php
echo "hello world";
$myfile = "CartFile.txt";
$fh = fopen($myfile,'r');
if ($fh) {
while (!feof($fh)) {
$buffer = fgets($fh);
echo $buffer;
}
fclose($fh);
}
?>
</body>
</html> Code: Select all
$txt = "Eagle: " . "Quantity: " . $FQ3 . " " . "Wood: " . $wood_status . " " . "Base: " . $base_status . " " . "Clock/Picture: " . $cp_status;
fwrite($fh,$txt); What's happening when I execute this code, on my screen, I see a black page come up and then the routines takes me back to my sites Home page.
I have learned that when PHP wants to use data from HTML form you code something like this:
Code: Select all
$FQ1 = $_POST["Quantity1"];My problem or question, how to a get the data, read via the print routine above, displayed on a Form.
To maybe give you a better idea of what I am trying to do is: I developed an Order Form that writes records to a flat-file called CartFile.txt(the code above is how it's done). On the form, I have a Submit button called "View Cart". When the user clicks the "View Cart" button, I want to display there order.