Guest User

Untitled

a guest
Aug 26th, 2013
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. <?php
  2. session_start();
  3. if ($_SESSION['uid'] == "") {
  4. header("Location: index.php");
  5. exit();
  6. }
  7. if (isset($_POST['topic_submit'])) {
  8. if (($_POST['topic_title'] == "") && ($_POST['topic_content'] == "")) {
  9. echo "You did not fill in both fields. Please retun to the previous page.";
  10. exit();
  11. } else {
  12. $tid='';
  13. include_once("connect.php");
  14. $cid = $_POST['cid'];
  15. $title = $_POST['topic_title'];
  16. $content = $_POST['topic_content'];
  17. $creator = $_SESSION['uid'];
  18. $sql = "INSERT INTO topics (category_id, topic_title, topic_creator, topic_date, topic_reply_date) VALUES ('".$cid."', '".$title."', '".$creator."', now(), now())";
  19. $res = mysql_query($sql) or die(mysql_error());
  20. $new_topic_id = mysql_insert_id();
  21. $sql2 = "INSERT INTO posts (category_id, topic_id, post_creator, post_content, post_date) VALUES ('".$cid."', '".$new_topic_id."', '".$creator."', '".$content."', now())";
  22. $res2 = mysql_query($sql2) or die(mysql_error());
  23. $sql3 = "UPDATE categories SET last_post_date=now(), last_user_posted='".$creator."' WHERE id='".$cid."' LIMIT 1";
  24. $res3 = mysql_query($sql3) or die(mysql_error());
  25. if (($res) && ($res2) && ($res3)) {
  26. header("Location: view_topic.php?cid=".$cid."&ti­d=".$new_topic_id);
  27. } else {
  28. echo "There was a problem creating your topic. Please try again.";
  29. }
  30. }
  31. }
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment