What happens is that my $file varible keeps getting reset when i hit submit im asubing that is because thae varible dosent transfer from the dispaly file info part to the submit new info part but im not sure how make it transfer can someone plz help me out.
<html>
<body>
<br><br>
<?=$errormessage?>
<br>
<?
$file=$HTTP_GET_VARS['number'];
$fd = fopen("file","r");
print "file $file";
while (!feof ($fd))
{
$t1=fgets($fd, 4096);
$t2=fgets($fd, 4096);
$t3=fgets($fd, 4096);
print "$t1";
print "$t2";
print "$t3";
print "<br>";
}
fclose($fd);
?>
<form action="<?=$SERVER['PHP_SELF']?>" method="post">
<table width="500" border="0" cellpadding="5" cellspacing="0">
<tr><td>Your name:</td><td><input type="text" name="name" value="<?=$POST['name']?>"></td></tr>
<tr><td>Your email:</td><td><input type="text" name="email" value="<?=$POST['email']?>"><td><tr>
<tr><td>Your message:</td><td><textarea name="message"><?=$POST['message']?></textarea></td></tr></table>
<input type="hidden" name="required" value="name,email,message">
<input type="submit" name="submit" value="submit">
<?php
$new="new";
//$file=$HTTP_GET_VARS['number'];
if ($POST['submit']) {
print "$file";
$required_fields = explode(",", $POST['required']);
$error = 0;
foreach($required_fields as $fieldname) {
if ($_POST[$fieldname] == "") {
$error++;
}
}
if ($error == 0) {
if (strstr($POST['email'], "@") and strstr($POST['email'], ".")) {
//If info is correct
$fp = fopen("$file","a");
fwrite($fp,$new);
fwrite($fp,$POST['name']);
fwrite($fp,$POST['email']);
fwrite($fp,$_POST['message']);
fclose($fp);
print "<br><html><body>Thank you for submitting your comments $_POST[name]!</body></html>";
exit;
} else {
print "<b>The email address you entered does not appear to be valid<br></b>";
}
} else {
print "<b>You have left some required fields in the form blank! Please fill in the form completely.";
}
}
?>
</body></html>