Is there a reason why my code does not want to write to my text file:guestbook.txt?
<?php
//Create a variable called $file that holds the guestbook.txt
$file= "guestbook.txt";
//Create other variables
$name= $_REQUEST['name'];
$message= $_REQUEST['message'];
//Check to make sure that all fields are populated
if(empty($name) || empty($message))
{
echo "<center><h3>Sorry, all fields are required</h3><center>";
}
else
{
/*Where $fp is the file pointer, and fopen Opens file or URL, $file is the $file(message.txt) and "a" means
Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.*/
$fp = fopen($file,"a");
//Use frwrite to write the write contents of string to the file stream pointed to by handle $fp.
fwrite($fp, '<font size="3">
<br />
<br />
Name: '.$name.'<br />
<br />
<br />Message: '.$message.'<br />
');
// Close the file pointed to by $fp.
fclose($fp);
echo '<font size="3">
<p align="center">Thank you '.$name.' for signing the Guestbook</p>
</font>';
}
?>