Habe die Suche und Google bis zum erbrechen gequält, aber leider noch keine passende antwort auf meine Frage gefunden.
Und zwar...
...ich möchte das ein Thread über ein Formular eröffnet wird.
Dafür habe ich auch schon folgenden Code gefunden.
Code: Alles auswählen
function autopost($message,$subject,$forum_id,$username,$user_id,$user_ip)
{
global $db;
$post_subject = $subject;
$post_message = $message;
$html_on = 0;
$bbcode_on = TRUE;
$smilies_on = TRUE;
$attach_sig = TRUE;
$topic_type = POST_NORMAL;
$topic_vote = 0;
$notify_user = 0;
$post_username = $username;
$bbcode_uid = make_bbcode_uid();
$mode == "newtopic";
$current_time = time();
$post_message = prepare_message($post_message, $html_on, $bbcode_on, $smilies_on, $bbcode_uid);
$sql = "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote)
VALUES ('" . str_replace("\'", "''", $post_subject) . "', " . $user_id . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_vote)";
if( $result = $db->sql_query($sql, BEGIN_TRANSACTION))
{
$new_topic_id = $db->sql_nextid();
}
else
{
message_die(GENERAL_ERROR, "Error inserting data into topics table", "", __LINE__, __FILE__, $sql);
}
$sql = "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, enable_bbcode, enable_html, enable_smilies, enable_sig) VALUES (";
$sql .= $new_topic_id.", ".$forum_id.", ".$user_id.", '".str_replace("\'", "''", $post_username) . "',". $current_time.", '".$user_ip."', ".$bbcode_on.", ".$html_on.", ".$smilies_on.", ".$attach_sig.")";
$result = $db->sql_query($sql);
if( $result )
{
$new_post_id = $db->sql_nextid();
$sql = "INSERT INTO " . POSTS_TEXT_TABLE . " (post_id, post_subject, bbcode_uid, post_text)
VALUES ($new_post_id, '" . str_replace("\'", "''", $post_subject) . "', '$bbcode_uid', '" . str_replace("\'", "''", $post_message) . "')";
if( $db->sql_query($sql) )
{
$sql = "UPDATE " . TOPICS_TABLE . " SET topic_first_post_id = ".$new_post_id.", topic_last_post_id = ".$new_post_id." WHERE topic_id = ".$new_topic_id;
if( $db->sql_query($sql) )
{
$sql = "UPDATE " . FORUMS_TABLE . " SET forum_last_post_id = ".$new_post_id.", forum_posts = forum_posts + 1";
$sql .= ", forum_topics = forum_topics + 1 WHERE forum_id = ".$forum_id;
if( $db->sql_query($sql) )
{
$sql = "UPDATE " . USERS_TABLE . " SET user_posts = user_posts + 1 WHERE user_id = ".$user_id;
if( $db->sql_query($sql, END_TRANSACTION))
{
@add_search_words($new_post_id, stripslashes($post_message));
}
}
}
}
}
//
// If we get here the post has been inserted successfully.
//
return $new_topic_id;
} // END OF autopost
Ich möchte aber das er in dem neuen thread auch ein umfrage erstellt, mit den auswahlmöglichkeiten z.b. Ja/Nein.
Wäre super wenn mir da einer weitehelfen könnte.
mfg schickimicky