On the first block of code, the second echo, all the contents should be in quotes and you need to terminate the line with a semicolon ";". And while not the issue you should note that your missing the opening <body> tag and you have 2 ending form tags (</form>).
And really I don't see why you are echoing all that html there is no php variables in it so I would just output it without the echo's. But if my guess is correct you are having different forms load for the user (if so you didn't show that code). In which case you may find it works better to do something like this
<body>
<?php
if ($formcheck) // whatever check you are performing
{
?>
<form action="pageTwo.php" method="post">
<!-- form html here-->
</form>
<?php
}
else
{
?>
<form action="pageTwo.php" method="post">
<!-- Some other form here -->
</form>
<?php
}
?>
</body>
On the second block of code. I noticed that the "fclose" and" fwrite" refer to a "$pageTwo" but the only variable in your code that opens a file is "$pageTwo1". The rest of the code looks like it will work, the only other possible issue would be if the file your opening is in a different directory (folder) than the php that is accessing it. In which case it is better to do the "is_writeable" check before you "fopen" the file, and then of course "fclose" the file at the end of the "if".
<?php
$name = addslashes($_POST['formName']);
$grade = addslashes($_POST['formgrade']);
if (is_writable('pageTwo1.txt'))
{
$pageTwo1 = fopen('pageTwo1.txt', 'ab');
if (fwrite($pageTwo1, $grade . ',' . $name . "\n"))
{
echo '<p>Thank you for submiting your grade</p>';
}
else
{
echo '<p>Cannot add your name to the grade book.</p>';
}
fclose($pageTwo1);
}
else
{
echo '<p>Cannot write to the file.</p>';
}
?>
Hope that helps.
I did want to leave some last thoughts on technique. In your first block of code you escaped all the double quotes (\"). If you use single quotes for php and double quotes for html you will seldom have to escape your quotes.
Also it is a good practice to always use brackets ({ and }) with your if's ifelse's and else's. While it works as is, a simple change could cause you a headache and/or lots of work.
And lastly it has been a long time since I seen "and" used in an "if", double ampersands (&&) in the majority of cases is better syntax. The php manual for [man]operators[/man] will give some idea of the difference (look at logical operators)