Hey
I have incorporated what you have commented and added a redirection for when I log out.
Should the settings be for all globals off? I don't know how to do that.
I'm just thinking of a way to have it so when I am logged in, it displays the posts as textfields with the option to update each one as well as delete them. Sould I have it so when I am logged in it displays the update form and delete option and if I am not then it displays the plain text?
So it is sort of the same script as displaying the login box when not logged in and displaying the post box when logged in.
Here is my update code. I really appreciate your help.
<?
$pword = "test";
session_start();
$page = myjournal;
include ("top.php");
?>
<h2><img src="myjournaltop.png" alt="My Journal" /></h2>
<br /><br />
<h3>
<?php
if (!$password) { // looks like register_globals is on?
echo '<form name=login method=post action="">
<input type=text name=password style="border-bottom: 1px solid #ccc; border-top: transparent;border-left:transparent;border-right:transparent;background-color:transparent;">
<input type=submit value="Post an entry perhaps?" style="border:1px solid #ccc;">
</form>';
} else {
if ($password==$pword) { // No need to quote the variable. Could be written if ($password==$pword)
session_register("password");
// OK great. You've registered it, but you never check to see if it's been
// registered before doing the insert below.
$form=true; // Works. But really it should be $form = true;
} else echo "Sorry you are not allowed to post<br />";
}
if ($m==1) {
session_unregister("password");
echo "<script language=\"JavaScript\" type=\"text/JavaScript\">
window.location= \"myjournal.php\"
</script>";
}
if ($postentry) { // here's where we should be checking to see if the session is registered
include ("connection.php");
$dateposted=date('jS F Y');
$title=$_POST['title']; // now looks like register_globals must be off?
$post=$_POST['post'];
$res = mysql_query ("INSERT INTO entries (title, entry, dateposted) VALUES
('$title', '$entry','$dateposted')");
if (!$res) {
die(mysql_error());
}
include ("close.php");
echo "<script language=\"JavaScript\" type=\"text/JavaScript\">
window.location= \"myjournal.php\"
</script>";
// Don't we have an errant '>' above?
}
if ($form==true) { // Again, it works. But this is probably better: if ($form == true)
echo '
<form method="post" action="" name="postentry">
<div style="border: 1px solid #ccc; padding: 3px; text-align:left;">
<a href="?m=1">Logout</a><br /><br />
<input type="text" name="title" style="border-bottom: 1px solid #ccc; border-top: transparent;border-left:transparent;border-right:transparent;background-color:transparent;"><br /><br /><textarea name="entry" rows="10" cols="40" style="border:1px solid #ccc;"></textarea><br /><br />
<input type="submit" value="Add" name="postentry" style="border:1px solid #ccc;">
</form>
</div>
';
}
include ("connection.php");
$qs="SELECT title,entry,dateposted FROM entries";
$re=mysql_query($qs);
// until you know it works it would be better to make this:
// $re=mysql_query($qs) or die(mysql_error());
while ($row=mysql_fetch_array($re, MYSQL_ASSOC)) {
echo "{$row['title']}<br /> " . "{$row['dateposted']}<br />" . "{$row['entry']}";
echo "<hr />";
}
include ("close.php");
?>
</h3>
<?php include ("footer.php"); ?>
I opened h3 tag at the top of the page.
Thanks