Here's the PHP code:
if (@$submit == "yes"){
$name = $_POST['name'];
$msg = $_POST['msg'];
$filename = 'rants.txt';
// Check to see if file exists and is writable first.
if (is_writable($filename)) {
// Open the file in append mode
if (!$handle = fopen($filename, 'ab')) {
print "Cannot open file ($filename)";
exit;
}
// Write $msg to the opened file.
if (!fwrite($handle, $msg)) {
print "Cannot write to file ($filename)";
exit;
}
fclose($handle);
}
else {
print "The file $filename is not writable";
}
}
Here's the code I have for my form:
<form action="index.php?submit=yes" method="post">
<input type="text" name="name" value="name"><br>
<input type="text" name="msg" value="short msg" maxlength="50"><br>
<input type="submit" value="submit">
</form>
I tested reading from the file after I put something in it.. and that worked ok. I've just been having trouble writing to the file after someone posts. Any ideas? I'll keep working at it.. thanks for your help.