Removing contents of a file after reading it
Posted: Fri Mar 18, 2005 5:51 pm
Hello, on my site i have a feedback forum
when the submit button is pressed it writes the fields into a text field then writes them out to a reciept.
Here is my code:
When i have read from the text file and displayed its contents how do i clear the text field?
Thanks for the help
Andy
feyd | Please review how to post code using
when the submit button is pressed it writes the fields into a text field then writes them out to a reciept.
Here is my code:
Code: Select all
<?php
$name = $_POST['Name'];
$email = $_POST['Email'];
$age = $_POST['age'];
$eqypt = $_POST['Egypt'];
$china = $_POST['China'];
$usa = $_POST['USA'];
$europe = $_POST['Europe'];
$rating = $_POST['Rating'];
$comments = $_POST['Comments'];
$SEPARATOR = "::";
$filename = 'c3042575.txt';
$details = "Name: $name".$SEPARATOR.
"Email: $email".$SEPARATOR.
"Age: $age".$SEPARAT
"Egypt? $eqypt".$SEPARATOR.
"USA? $usa".$SEPARATOR.
"China? $china".$SEPARATOR.
"Europe? $europe".$SEPARATOR.
"Rating: $rating".$SEPARATOR.
"Comments: $comments".$SEPARATOR;
$file = fopen($filename,"a");
fputs ($file, $details);
fclose($file);
$file = fopen($filename,"r");
$contents = fread($file, filesize($filename));
$arrayContents = explode($SEPARATOR, $contents);
for ($i=0; $i<count($arrayContents); $i++)
{
echo ($arrayContents[$i]."<br />");
}
?>Thanks for the help
Andy
feyd | Please review how to post code using
Code: Select all
andCode: Select all
tags. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]