Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi,
I've been recently trying to build a CMS system for a new site of mine, everything's working fine so far. (Adding, Viewing & Deleting items)
but now I'm trying to get the Editing part of the CMS going, the title & content is displayed perfectly in the form, but absolutely nothing happens when I click the submit button. In fact it reverts to the original content.
What I'm trying to accomplish is from this tutorial - http://www.php-mysql-tutorial.com/cms-a ... -mysql.php
note, I've taken the cache out from that tutorial because my site is small and doesnt need it. viewing & deleting items works just fine without the cache.
I've also taken out the library php files it includes (config.php, opendb.php etc.) because the information in those is contained in my code, and once again, the other pages work fine without.Code: Select all
<?php
session_start();
if (!isset($_SESSION['basic_is_logged_in']) || $_SESSION['basic_is_logged_in'] !== true) {
// not logged in, move to login page
header('Location: index.php');
exit;
}
?>
<?php
$hostname = 'p50mysql1.secureserver.net';
$username = 'bull';
$password = '*****';
$dbname = 'bull';
mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
mysql_select_db($dbname);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CMS Donate</title>
<link href="../_include/cms.css" rel="stylesheet" type="text/css" />
</head>
<body>
<center>
<h1>Donate Menu</h1>
<br />
<!-- #BeginLibraryItem "/_library/navCmsTop.lbi" -->
<!-- Start -->
<ul class="navCmsTop">
<li><a href="../cms/admin.php">Home</a></li>
<li><a href="../cms/donate.php">Donate</a></li>
<li><a href="../cms/environment.php">Environment</a></li>
<li><a href="../cms/interest_rates.php">Interest Rates</a></li>
<li><a href="../cms/news.php">News</a></li>
<li><a href="../cms/video.php">Video</a></li>
<li><a href="../cms/work_choices.php">Work Choices</a></li>
<li><a href="../cms/logout.php">Logout</a></li>
</ul>
<!-- End -->
<!-- #EndLibraryItem -->
<div class="content">
<?php
if(isset($_GET['id']))
{
$query = "SELECT id, title, content ".
"FROM `donate` ".
"WHERE id = '{$_GET['id']}'";
$result = mysql_query($query) or die('Error : ' . mysql_error());
list($id, $title, $content) = mysql_fetch_array($result, MYSQL_NUM);
$content = htmlspecialchars($content);
}
else if(isset($_POST['save']))
{
$id = $_POST['id'];
$title = $_POST['title'];
$content = $_POST['content'];
if(!get_magic_quotes_gpc())
{
$title = addslashes($title);
$content = addslashes($content);
}
// update the article in the database
$query = "UPDATE `donate` ".
"SET title = '$title', content = '$content' ".
"WHERE id = '$id'";
mysql_query($query) or die('Error : ' . mysql_error());
echo "<p>Item '$title' updated</p>";
// now we will display $title & content
// so strip out any slashes
$title = stripslashes($title);
$content = stripslashes($content);
}
?>
<form method="post">
<input type="hidden" name="id" value="<?=$id;?>">
<table class="view">
<tr>
<td style="width: 75px;">Title</td>
<td style="width: 425px;"><input name="title" type="text" id="title" value="<?=$title;?>" style="width: 300px;" /></td>
</tr>
<tr>
<td style="width: 75px;">Content</td>
<td style="width: 425px;"><textarea name="content" cols="68" rows="10" id="content"><?=$content;?></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2" style="text-align: center;"><input name="update" type="submit" id="update" value=" Update Article "></td>
</tr>
</table>
<br />
<p><a href="donate.php">Back</a></p>
</form>
</div>
</center>
</body>
</html>note, I've tried this to no success
Code: Select all
<input type="hidden" name="id" value="<?php echo $id;?>">
<table class="view">
<tr>
<td style="width: 75px;">Title</td>
<td style="width: 425px;"><input name="title" type="text" id="title" value="<?php echo $title;?>" style="width: 300px;" /></td>
</tr>
<tr>
<td style="width: 75px;">Content</td>
<td style="width: 425px;"><textarea name="content" cols="68" rows="10" id="content"><?php echo $content;?></textarea></td>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]