Jump to content

Update help


ryeman98

Recommended Posts

I have everything working except for the update. Here is the info.

 

Edit form:

<?php
} elseif ($_GET['action'] == "edit") {

$id = $_POST['id'];
$edit = mysql_query("SELECT * FROM news WHERE id='$id'");
$display = mysql_fetch_array($edit);

echo "
<table border=0 cellpadding=0 cellspacing=2>
<form name=\"editarticle\" action=\"/article.php?action=update\" method=\"post\">
<tr valign=top><td><strong>Title:</strong></td> <td><input type=\"text\" name=\"title\" size=\"60\" value=".$display['title']." /></td></tr>
<tr valign=top><td><strong>Date:</strong></td> <td><input type=\"text\" name=\"date\" value=".$display['date']."</td></tr>
<tr valign=top><td><strong>Content:</strong></td> <td><textarea name=\"content\" maxlength=\"10000\" cols=\"50\" rows=\"10\">".$display['content']."</textarea></td></tr>
<tr valign=top><td><strong>Password:</strong></td> <td><input type=\"password\" name=\"password\" /></td></tr>
<tr align=right><td></td><td><input type=\"submit\" name=\"submit\" value=\"Edit Article\" /></td></tr>
</form></table>";
}

 

Update code:

<?php
elseif ($_GET['action'] == "update") {

$title = $_POST['title'];
$date = $_POST['date'];
$content = $_POST['content'];

if ($_POST['password'] == "oilersrock") {
$update1 = ("UPDATE SET title='$title'")
or die(mysql_error());
$update2 = ("UPDATE SET date='$date'")
or die(mysql_error());
$update3 = ("UPDATE SET content='$content'")
or die(mysql_error());
	echo "Your article has been updated.";
}
}
?>

 

I've tried a few things. Maybe I'm just tired but anyways, thanks in advance!

Rye

Link to comment
https://forums.phpfreaks.com/topic/53956-update-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.