Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.