Wrox Programmer Forums
|
BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143
This is the forum to discuss the Wrox book Beginning PHP 6, Apache, MySQL 6 Web Development by Timothy Boronczyk, Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz; ISBN: 9780470391143
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 4th, 2009, 02:15 PM
Registered User
 
Join Date: Oct 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Talking CH13 problems solved with code tags

cms_transact_user moderate as follows:

code
case 'Modify Account':
if (isset($_POST['name'])
and isset($_POST['email'])
and isset($_POST['access_level'])
and isset($_POST['user_id']))
{
$sql = "UPDATE cms_users " .
"SET email='" . $_POST['email'] .
"', name='" . $_POST['name'] .
"', access_level=" . $_POST['access_level'] . " " .
" WHERE user_id=" . $_POST['user_id'];

mysql_query($sql, $db)
or die('Could not update user account; ' . mysql_error());
}
redirect('cms_admin.php');
break;
/code

and cms_transact_article as follows

code

<?php
session_start();
require_once 'db.inc.php';
require_once 'cms_http_functions.inc.php';
$db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or
die ('Unable to connect. Check your connection parameters.');

mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db));

if (isset($_REQUEST['action'])) {
switch ($_REQUEST['action']) {
case 'Submit New Article':
if (isset($_POST['title'])
and isset($_POST['article_text'])
and isset($_SESSION['user_id']))
{
$sql = "INSERT INTO cms_articles " .
"(title,article_text, user_id, submit_date) " .
"VALUES ('" . $_POST['title'] .
"','" . $_POST['article_text'] .
"'," . $_SESSION['user_id'] . ",'" .
date("Y-m-d H:i:s", time()) . "')";

mysql_query($sql, $db)
or die('Could not submit article; ' . mysql_error());
}
redirect('cms_index.php');
break;

case 'Edit':
redirect('cms_compose.php?a=edit&article=' . $_POST['article']);
break;

case 'Save Changes':
if (isset($_POST['title'])
and isset($_POST['article_text'])
and isset($_POST['article_id']))
{
$sql = "UPDATE cms_articles " .
"SET title='" . $_POST['title'] .
"', article_text='" . $_POST['article_text'] . "', submit_date='" .
date("Y-m-d H:i:s", time()) . "' " .
"WHERE article_id=" . $_POST['article_id'];
if (isset($_POST['user_id'])) {
$sql .= " AND user_id=" . $_POST['user_id'];
}

mysql_query($sql, $conn)
or die('Could not update article; ' . mysql_error());
}

if (isset($_POST['user_id'])) {
redirect('cms_cpanel.php');
} else {
redirect('cms_pending.php');
}
break;

case 'Publish':
if ($_POST['article_id']) {
$sql = "UPDATE cms_articles " .
"SET is_published=1, publish_date='" .
date("Y-m-d H:i:s",time()) . "' " .
"WHERE article_id=" . $_POST['article_id'];
mysql_query($sql, $db)
or die('Could not publish article; ' . mysql_error());
}
redirect('cms_pending.php');
break;

case 'Retract':
if ($_POST['article_id']) {
$sql = "UPDATE cms_articles " .
"SET is_published=0, publish_date='' " .
"WHERE article_id=" . $_POST['article_id'];
mysql_query($sql, $conn)
or die('Could not retract article; ' . mysql_error());
}
redirect('cms_pending.php');
break;

case 'Delete':
if ($_POST['article_id']) {
$sql = "DELETE FROM cms_articles " .
"WHERE is_published=0 " .
"AND article_id=" . $_POST['article_id'];
mysql_query($sql, $conn)
or die('Could not delete article; ' . mysql_error());
}
redirect('cms_pending.php');
break;

case 'Submit Comment':
if (isset($_POST['article_id'])
and $_POST['article_id']
and isset($_POST['comment'])
and $_POST['comment'])
{
$sql = "INSERT INTO cms_comments " .
"(article_id,comment_date,user_id,comment_text ) " .
"VALUES (" . $_POST['article_id'] . ",'" .
date("Y-m-d H:i:s", time()) .
"'," . $_SESSION['user_id'] .
",'" . $_POST['comment_text'] . "')";
mysql_query($sql, $conn)
or die('Could add comment; ' . mysql_error());
}
redirect('cms_view_article.php?article=' . $_POST['article_id']);
break;

case 'remove':
if (isset($_GET['article_id'])
and isset($_SESSION['user_id']))
{
$sql = "DELETE FROM cms_articles " .
"WHERE article_id=" . $_GET['article_id'] .
" AND user_id=" . $_SESSION['user_id'];
mysql_query($sql, $conn)
or die('Could not remove article; ' . mysql_error());
}
redirect('cms_cpanel.php');
break;
}
} else {
redirect('cms_index.php');
}
?>
/code





Similar Threads
Thread Thread Starter Forum Replies Last Post
ch13 more errors solved sporik BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 0 December 4th, 2009 02:04 PM
Problems transforming embedded html tags Brad Harrington XSLT 1 February 10th, 2009 04:53 PM
Solved:VB Code Asks for Password to UnZip!! flashster BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 4 August 23rd, 2006 01:55 PM
code runs when not suppose to! (solved) dhaywirex Classic ASP Basics 13 February 19th, 2004 08:26 AM
VB.NET Edition code problems Solved charul_shukla BOOK: ASP.NET Website Programming Problem-Design-Solution 5 July 11th, 2003 01:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.