I'm missing a Basic PHP Concept

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SamCec
Forum Newbie
Posts: 17
Joined: Mon Aug 16, 2010 11:43 am

I'm missing a Basic PHP Concept

Post by SamCec »

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:
<

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> 
In the file "CartFile.txt", there are 2 records. these records, when written, were written with code like this:

Code: Select all

$txt =  "Eagle: " . "Quantity: " . $FQ3 .  "     " . "Wood: " .  $wood_status . "     " . "Base: " . $base_status . "     " . "Clock/Picture: " . $cp_status;
fwrite($fh,$txt);  
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:

Code: Select all

$FQ1 = $_POST["Quantity1"];
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.
Post Reply