Alright, I just got done resolving another problem when this one popped up. First of all, I am calling up a page to edit various news articles. The page prior sends the news id to this page, and it is supposed to display the data for editing, then update it in the mySQL. The problem is, it is getting the number, running the else statement, but after I hit submit, it clears the newsid number. Here is the code:
<html>
<head><title> News Edit</title></head>
<body bgcolor="#A3A3A2">
<?php
$newsid = $_GET['newsid'];
/* declare some relevant variables */
$DBhost = "localhost";
$DBuser = "pspnetw_kraft";
$DBpass = "nick4033";
$DBName = "pspnetw_pspdata";
$table = "psp_news";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable toconnect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName");
$sql = "SELECT * FROM psp_news WHERE newsid='$newsid'";
$result = mysql_query($sql);
if($_POST["submit"]) {
$newstitle = $_POST['newstitle'];
$summary = $_POST['summary'];
$fullarticle = $_POST['fullarticle'];
$sql = "UPDATE psp_news SET newstitle='$newstitle', summary='$summary', fullarticle='$fullarticle' WHERE newsid='$newsid'";
$result = mysql_query($sql);
echo "News entered!";
} else {
$sql = "SELECT * FROM psp_news where newsid='$newsid'";
$result = mysql_query($sql);
$an_object = mysql_fetch_object($result);
$newstitle = $an_object->newstitle;
$summary = $an_object->summary;
$fullarticle = $an_object->fullarticle;
echo $newstitle;
print "
<FORM METHOD=POST ACTION='" . $PHP_SELF . "'>
<TABLE>
<TR><TD>
<INPUT TYPE='text' NAME='newstitle' VALUE='$newstitle'><br><br>
<TEXTAREA NAME='summary' ROWS=8 COLS=100>$summary</text><br>
<TEXTAREA NAME='fullarticle' ROWS=14 COLS=100>$fullarticle</text><br>
<p><INPUT TYPE='submit' name='submit' value='Submit News'></td></tr>
</TABLE></FORM></body></html> ";
}
?>
Any clue on what I can do?