Log in

View Full Version : Form to update page - part II



Glen_S
07-11-2006, 08:00 PM
Ok, what was suggested in an earlier thread about using php to let a user update a web page was a tad complex (for me, anyway:) ) so I came up with the following: (after much tedious slogging thru various tutorials I might add)

I created a page called update.html that the user will access, the code is here:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>news input page</TITLE>
</HEAD>
<BODY>
<FORM method="POST" action="testform.php">
Type in information here: <br>
<textarea name="comment" cols="60" rows="20"></textarea><BR>
Type in your password:
<input type="password" name="password">
<INPUT type="submit" name="mybutton" value="Submit Information"><br>
</form>
</FORM>
</BODY>
</HTML>

Not very pretty, but I'll worry about that later, it seems to work when updating my results.php page:


<HTML>
<HEAD>
<TITLE>test results page</TITLE>
</HEAD>
<BODY>
<?
if ($_POST['password'] != "blahblah") { die(); }
if(isset($_POST['mybutton']))
{
echo "<BR>Comments are accepted, you posted: " . $_POST['comment'] . "\n";
} else {
echo "Your Post was not accepted, did you type the right password? \n";
}
?>

Click <a href="newstest.html">here</a> to view!
</BODY>
</HTML>

it more or less works, except for the "post not accepted" message, but thats no biggie right now.

Now, rather than have it update this page, I'd like it just to send the entered text to a file that I could have a pointer to in my div box on my newstest.html page.

A redirect to the page if the password was correct would be nice as well, but at this point its a "nice to have", right now I just want to get it working.

How do I go about getting this to write to a file now, and is an include the best way to have it display in my <div> box?