Fair enough. This script is supposed to view a blog title and entry that has been passed to it from the previous page using the entryid variable. It views the information in the content of a form so that changes could be made to the existing information and modified in the database upon hitting the submit button. After that, I don't mind if the form fields are blank, as long as the information was updated. I didn't think I had to pass the entryid value again, since it was established earlier it should still exist, right?
Here is the full code as it is right now, may2004 is the table name:
PHP Code:
<?
$lnk = mysql_connect('mysql address', 'login', 'password') or die (mysql_error());
mysql_select_db('databasename',$lnk);
$sql = "SELECT title,entry FROM may2004 WHERE id = '".$entryid."'";
$result = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$title = stripslashes($row['title']);
$entry = stripslashes($row['entry']);
}
?>
<form method="post" action="<?=$PHP_SELF?>"><?php echo($entryid); ?> <input type="text" name="newtitle" value="<?php echo($title); ?>"><br /><textarea name="newentry" rows="10" cols="70"><?php echo($entry); ?></textarea><br /><input type="Submit" name="submitentry" value="submit"></form>
<?php if ($submitentry == "submit") {
$updquery = "UPDATE may2004 SET title='".$newtitle."',entry='".$newentry."' WHERE id='".$entryid."'";
mysql_query($updquery,$lnk) or die(mysql_error());
echo $sql . "<br><br>\n";
echo("<p>Your entry has been updated.</p>"); }
?>