Welcome Guest ( Log In | Register)



 
Closed TopicStart new topic
> [forum] Double Posting Happening By An Error
Arne-Christian
post Oct 30 2006, 05:58 PM
Post #1


Member [Level 1]
****

Group: Members
Posts: 62
Joined: 22-December 05
From: Sandefjord,Norway
Member No.: 16,078



Hello,
I am currently working on EvilBoard 0.1.1, for those who know about this project versjon 0.1b can be downloaded from http://www.evilservices.com

Well over to the reason why i am posting this,
I am currently experincing a problem with my new posting code wich has been rewrited in version 0.1.1, You see, it is double posting by an error, i thouht i could fix that myself, but no, so i just thought, Trap17 is perfect, they problety know how to fix this,

Here is the code:
CODE
<?
/*
* @Name: Post Topic
* @Author: Arne-Christian Blystad
* @Copyright: Copyright 2006 EvilServices
*
* @ID: $i29-10-06-eb011
*/
session_start();
global $template;
include("source/lib/eb.php");
include("smarty/smarty.class.php");
$template = new Smarty;
$post = new post;
if(isset($_POST['Submit'])) {
        echo $post->post();
        $x = $post->get_last_topic();
        $f = $_GET['forumid'];
        @header("location: redirect.php?url=index.php?act=showtopic_t={$x}_forumid={$f}");
}
else {
    echo $post->post_new();
}
//===========================
// Class: Post
// Desc: Required for posting new topics, and replies
//===========================
class post {
    function post_new()
    {
        include("lang/en/lang_en.php");
        $template = new smarty;    
        $eb = new eb;
        $eboard = new eboard;
        $forumname = $eboard->forum_name();
        $template = new smarty;
        $name = $_SESSION['user_name'];
        if($name) {
            $template->assign("name","$name");
        }
        $template->assign("lvl","{$_SESSION[user_level]}");
            $menu = $_SESSION['user_name'];
        if($menu) {
            $template->assign("menu","true");
        }
        $lvl = $_SESSION['user_level'];
        if($lvl == "3") {
            $template->assign("lvl","3");
        }
        if($_GET['do'] == "post_new") { $title = "Post new topic"; }
        else { $title = "Post reply"; }
        $template->assign("title","{$title} - {$forumname}");
        $template->assign("forum_name","{$forumname}");
        $template->template_dir = "/Themes/Default/";
        $template->compile_dir = "cache/";
        if($_GET['do'] == "post_new") {
            $template->assign("post_new","true");
        }
        else {
        
        }
        $template->display("post.tpl");
    }
    function post()
    {
        // Connect to DB
        $db = new db;
        $db->connect();
        // Check if topic is submited
                // Defines variables for title, description and post message
                $title    =    $_POST['t_title'];
                $desc    =    $_POST['t_desc'];
                $msg    =    $_POST['writer'];
                
                // Conencts to DB
                $db = new db;
                $db->connect();
                // Check if t_title or writer is null
                if($_GET['do'] == "post_new") {
                    if(empty($title)) { $err = "102 - Could not post - Title is null"; }
                }
                if(empty($msg)) { $err = "103 - Could not post - Message is null"; }
                // If something is null, cancel the sending!
                if($err) {
                    $template = new smarty;
                    // this is smarty stuff required for the first page
                    $name = $_SESSION['user_name'];
                    if($name) {
                        $template->assign("name","$name");
                    }
                    $template->assign("lvl","{$_SESSION[user_level]}");
                        $menu = $_SESSION['user_name'];
                    if($menu) {
                        $template->assign("menu","true");
                    }
                    $lvl = $_SESSION['user_level'];
                    if($lvl == "3") {
                        $template->assign("lvl","3");
                    }
                    // Sets title to Post new topic ,or port reply
                    if($_GET['do'] == "post_new") { $title = "Post new topic"; }
                    else { $title = "Post reply"; }
                    // Asigns title and forum name
                    $template->assign("title","{$title} - {$forumname}");
                    $template->assign("forum_name","{$forumname}");
                    // Sets folders for template and cache dir.
                    $template->template_dir = "/Themes/Default/";
                    $template->compile_dir = "cache/";
                    // If were posting a new topic, we need to show the Title: and Description:.
                    if($_GET['do'] == "post_new") { $template->assign("post_new","true"); }
                    $template->assign("err","{$err}"); $template->display("post.tpl"); exit();
                }
                else {
                    // Ok here we are, now it is going to send the info to DB, because we know its error free.
                
                    // Defines variables.
                    $this->userid        =    $_SESSION['userid'];
                    $this->title        =    $_POST['t_title'];
                    $this->desc            =    $_POST['t_desc'];
                    $this->usrn            =    $_SESSION['user_name'];
                    $this->forumid        =    $_GET['forumid'];
                    $this->ip_addrs        =    $_SERVER['REMOTE_ADDR'];
                    $this->is_sticky    =    $_POST['is_sticky'];
                    $this->is_closed    =    $_POST['is_closed'];
                    $this->msg            =    $_POST['writer'];
                    $this->time            =    time();
                    
                    // If this is a new topic, create the topic!
                    if($_GET['do'] == "post_new") {
                        $db->query("INSERT INTO `eb_topic` ( `UserID` , `title` , `TopicID` , `replies` , `desc` , `Username` , `ForumID`, `is_sticky`, `is_closed` )
        VALUES ('$this->userid', '$this->title', NULL , '0', '$this->desc', '$this->username', '$this->forumid','$this->is_sticky','$this->is_closed');") or die("MySQL Error: " . mysql_error());
                    }
                    else {
                    // * If this isn't a topic, simply don't create the topic!
                    }
                    // Get the last topic from the database
                    $this->last = $this->get_last_topic();
                    // Inserts Reply
                    $post = $db->query("INSERT INTO `eb_post` ( `message` , `postdate` , `UserID` , `Username` , `PostID` , `TopicID` , `ForumID` , `title` , `user_ip` )
        VALUES (
        '$this->msg', '$this->time' , '$this->userid', '$this->username', '' , '$this->last', '$this->forumid', '$this->title', '$this->ip_addrs');") or die("MySQL Error: " . mysql_error());
                } // End Error free inserting.
    }
    function get_last_topic()
    {
        $db = new db;
        $db->connect();
        $topic = $db->query("SELECT * FROM `eb_topic` ORDER BY `TopicID` DESC LIMIT 0,1");
        $topic = $db->fetch_array($topic);
        $topic = $topic['TopicID'];
        return $topic;
    }
}
?>

I hope any of you can help me, The one who helps me can get added to * Special Thanks to: [USERNAME HERE]
in the file, and trap17 is allready added to the special thanks to file smile.gif

Arne-Chrisitan Blystad - EvilBoard Devloper smile.gif
Go to the top of the page
 
+Quote Post
Saint_Michael
post Oct 31 2006, 01:22 AM
Post #2


$p4m 0n j00 $h4m3 m3 0nc3 $p4m 0n m3 $h4m3 m3 7\/\/1c3
*********************

Group: [HOSTED]
Posts: 6,305
Joined: 21-September 04
From: 9r33|\| 399$ 4|\|D 5P4/\/\
Member No.: 1,218
T17 GFX Crew



Although I can't see it right now, but I would think you have an extra line possibly an echo that makes the 2 posts try your search around that conclusion.
Go to the top of the page
 
+Quote Post
Arne-Christian
post Oct 31 2006, 04:31 PM
Post #3


Member [Level 1]
****

Group: Members
Posts: 62
Joined: 22-December 05
From: Sandefjord,Norway
Member No.: 16,078



QUOTE(Saint_Michael @ Oct 31 2006, 01:22 AM) *

Although I can't see it right now, but I would think you have an extra line possibly an echo that makes the 2 posts try your search around that conclusion.

Thanks, that fixed it, i just changed $post->post(); to $post->post_topic(); and including changing the name, that fixed it all smile.gif ph34r.gif
Go to the top of the page
 
+Quote Post
Saint_Michael
post Oct 31 2006, 05:38 PM
Post #4


$p4m 0n j00 $h4m3 m3 0nc3 $p4m 0n m3 $h4m3 m3 7\/\/1c3
*********************

Group: [HOSTED]
Posts: 6,305
Joined: 21-September 04
From: 9r33|\| 399$ 4|\|D 5P4/\/\
Member No.: 1,218
T17 GFX Crew



ROCK ON!!! I solved it without even trying laugh.gif Topic is closed.
Go to the top of the page
 
+Quote Post

Closed TopicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Wap Forum(9)
  2. Parse: Error Unexpected T_lnumber(4)
  3. Phpskye The New Forum Software.(4)
  4. Php Form Help!(3)
  5. Posting To An External Site Without Url Change(0)
  6. Do Somebody Have A Tutorial About... How To Create A Forum?(11)
  7. Free Web Forum Scripts?(7)
  8. Freetype, Gd And An Error(1)
  9. Uglymonkey Toplist Script(7)
  10. Detect Image Resolution Without Gd(1)
  11. Evilboard (forum Software) - Multiple Categorys - Don't Work :((6)
  12. Ipb Multi Forum (hosting Mod)(6)
  13. Help Needed With Silly Error(8)
  14. Error Importing Sql Query Via Php(6)
  15. Php Forum Signature(10)
  1. Error With Joomla Template(1)
  2. Error On Emailer.php & Smtp.php At Phpbb(2)
  3. Php Fsockopen() Error(14)
  4. Phpbb2 Error(4)
  5. How To Display The Latest Forum Post On Main Page(4)
  6. Forum Troubles(2)
  7. T_string Error Please Assist(5)
  8. Creating A Login Box That Links To My Phpbb Forum(4)
  9. Forum Last Post And Avatar(5)
  10. Php Objects: Catchable Fatal Error(4)
  11. Forum Script(3)
  12. Manage Double Posting In Php(4)
  13. Mysql Error(3)


 



- Lo-Fi Version Time is now: 25th July 2008 - 10:12 AM