The contents of a simple mailform do not get written to a .txt file. They do get sent to a specified email address, though (you can check it out at [URL=”http://mailbox-it.com/dobbs/tests/writeToFile.html”]Mail Form
[B]Could someone point out the error preventing the PHP code to write values to the file? [COLOR=”DarkRed”]Eventually, my goal is to write the mailform contents back to an .html file [B]from this .txt file
Here is the code:
[code=php]
<?php
if (isset($_POST[‘submit’])) {
$sent = mail($_POST[‘to’],$_POST[‘subject’],$_POST[‘message’],”From: ” . $_POST[‘from’]);
if ($sent) {
echo “Mail sent”;
}
else{
echo “There was an error sending your mail”;
}
//open write and close file
$fp = fopen(“log.txt”, “a”);
fwrite($fp, $_POST[‘to’] . ” ” . $_POST[‘from’] . “n”);
fclose($fp);
}
?>
[CODE]
<html>
<head>
<title>Contact Form</title>
</head>
<body>
<form action=”writeToFile.php” method=”post”>
<table>
<tr>
<td>To:</td>
<td><input type=”text” name=”to” /></td>
</tr>
<tr>
<td>From:</td>
<td><input type=”text” name=”from” /></td>
</tr>
<tr>
<td>Subject:</td>
<td><input type=”text” name=”subject” /></td>
</tr>
<tr>
<td>Message:</td>
<td><textarea name=”message” rows=”6″ cols=”50″></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type=”submit” name=”submit” value=”send” /></td>
</tr>
</table>
</form>
</body>
</html>[/CODE]
Please help! I do need it. Thank you.