I am writing a simple ordering system where several numbers (filled inside the form) are written to another .php file (maybe also .html) using a function fopen. This works great, but after writing to a file, I want the browser to actually open this file, preferably in a new browser window. So my client can use this for printing, use as an invoice, etc.
Now I am still new to php-based and have no experience using it fopen. But everywhere I look for textbooks, etc., He said that he fopenopens (or, of course, writes) a file, but this is not as far as I knew. It seems to allow access to the specified file for writing and reading, rather than actually displaying the newly written page.
To avoid confusion: I do NOT want to open links, like the other questions here, in SO state.
My code is:
<form action="" method="post">
<input type="text" id="amountTuna" name="numberTuna" value="0"/>
<input type="text" id="amountCheese" name="numberCheese" value="0"/>
<input name="send" id="send" type="submit" value="Post order" />
</form>
<?php
if (array_key_exists('send', $_POST)) {
$order = "order.php";
$fh = fopen($order, 'w') or die("can't open file");
fwrite($fh, "Tuna sandwiches: " . stripslashes($_POST['numberTuna']));
fwrite($fh, "Cheese sandwiches: " . stripslashes($_POST['numberCheese']));
$fh = fopen($factuur, 'r');
$fileip = fread($fh, filesize($factuur));
fclose($fh);
}
?>
Attempting to use different parameters fopen, such as 'w', 'r', 'r+', etc., it does not seem to make any difference. Removal fclose($fh)also does not matter.
source
share