Well, first, please place any further code posts inside of the PHP tags. It is much easier for us to view them if
they are in the tags as they should be.
Now, the code you posted makes no sense at all. You have random braces around some code { } and more
of them in the wrong place and some missing… Here is your code posted inside PHP tags. Notes follow…
[php]
testcomment
<?php
function escape ($string) {
return htmlspecialchars($string, ENT_QUOTES, "UTF-8");
require 'testcomment.php';
$name = escape($name);
$email = escape($email);
$website = escape($website);
$message = escape($message);
$time = time();
if (!$name || !$email || !$website || !$message) {
echo “*Please fill out required fields”;
} else {
if(strlen($name) > 0 && strlen($message)> 0) {
(filesize(‘testcomments.log’) > 0);
}
}
$outputstring = $pre. ‘
’.$message.’
’;
@fwrite($fp, $outputstring, strlen($outputstring));
fclose($fp);
{ Header(‘Location:testcomments.log’); }
}
?>
Comments:
<?php include("testcomments.log");?>
[/php]
Line #8 creates a function which returns a result on the next line, but, is missing the closing brace!
Line #11 what is in this file? If it does not pertain to your post, never mind…
Line #13 to #16 use the function that is missing closure. Also, the variables are not pulled from $_POST array
Line #22 is an IF CLAUSE, then has another IF CLAUSE for the results if valid. Makes no sense!
Line #27 writes to a file $fp, but, never opens that file handle!
Line #27 suppresses error messages when writing so you do not know if it worked or not.
Line #30 has braces around the header function. No need for the braces.
Line #32 is a random brace and not needed
Line #45 creates a submit button, but, you never test for it in your PHP code. You would need that to see
if the user presses the button… Loosely like: if (isset($_POST[“submit”]) { do your processes }
As you see, you need a lot of work to fix up this code. Good luck. Hope this helps get you started…