View Single Post
 
Old September 21st, 2010, 04:30 PM
DMatt DMatt is offline
Authorized User
Points: 152, Level: 3
Points: 152, Level: 3 Points: 152, Level: 3 Points: 152, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2010
Location: Bra - Italy
Posts: 36
Thanks: 1
Thanked 1 Time in 1 Post
Default

Ok, i fix it... finally...

For enter the article data in the database and show them, we have to modify 2 script: cms_transact_article.php and cms_compose.php

The right solution for cms_transact_article is here:
PHP Code:
case 'Submit New Article':
        
$title = (isset($_POST['title'])) ? $_POST['title'] : '';
        
$article_text = (isset($_POST['article_text'])) ? $_POST['article_text'] : '';
        
$user_id = (isset($_POST['user_id'])) ? $_POST['user_id'] : '';
    if (!empty(
$user_id) && !empty($title) && !empty($article_text)) {
            
$sql "INSERT INTO cms_articles
        (user_id, submit_date, title, article_text)
        VALUES
        ('
$user_id', NOW(), '$title', '$article_text')";

            
mysql_query($sql$db) or die (mysql_error($db));
        }
        
redirect('cms_index.php');
        break; 
and the cms_compose is here:
PHP Code:
if (empty($article_id)) {
    echo 
'<input type="hidden" name="user_id" value="' $_SESSION['user_id'] . '"/>';
    echo 
'<input type="submit" name="action" value="Submit New Article"/>'
The problem was an incorrect syntax of mysql instructions and the value of $_SESSION['user_id'] that wasn't passed through the pages.. As you look i've fix the syntax problems first, and after set user_id like a "post" data..

The comments have the same problems... This book is full of f*****g errors..