Opdatere ikke
Goddag..Jeg har hentet et simpelt nyhedssystem som burde virke, men det gør det vidst ikke..
Jeg kan ikke redigere mine nyheder, hvilket jeg er meget irriteret over..
Håber nogen kan hjælpe mig..
Her er koden:
<html>
<head></head>
<body>
<!-- standard page header -->
<?php
// includes
include('conf.php');
include('functions.php');
// form not yet submitted
// display initial form with values pre-filled
if (!$_POST['submit'])
{
// check for record ID
if ((!isset($_GET['id']) || trim($_GET['id']) == ''))
{
die('Missing record ID!');
}
// open database connection
$connection = mysql_connect($host, $user, $pass)
or die ('Unable to connect!');
// select database
mysql_select_db($db) or die ('Unable to select database!');
// generate and execute query
$id = $_GET['id'];
$query = "SELECT title, content, contact FROM news
WHERE id = '$id'";
$result = mysql_query($query)
or die ("Error in query: $query. " . mysql_error());
// if a result is returned
if (mysql_num_rows($result) > 0)
{
// turn it into an object
$row = mysql_fetch_object($result);
// print form with values pre-filled
?>
<table cellspacing="5" cellpadding="5">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<tr>
<td valign="top"><b><font size="-1">Title</font></b></td>
<td>
<input size="50" maxlength="250" type="text" name="title"
value="<?php echo $row->title; ?>">
</td>
</tr>
<tr>
<td valign="top"><b><font size="-1">Content</font></b></td>
<td>
<textarea name="content" cols="40" rows="10">
<?php echo $row->content; ?>
</textarea>
</td>
</tr>
<tr>
<td valign="top"><font size="-1">Contact person</font></td>
<td>
<input size="50" maxlength="250" type="text" name="contact"
value="<?php echo $row->contact; ?>">
</td>
</tr>
<tr>
<td colspan=2>
<input type="Submit" name="submit" value="Update">
</td>
</tr>
</form>
</table>
<?php
}
// no result returned
// print graceful error message
else
{
echo '<font size=-1>That press release could not be located
in our database.</font>';
}
}
else
{
// form submitted
// start processing it
}
?>
<!-- standard page footer -->
</body>
</html>