Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Form:
- echo "<form action='forums.php' method='post'>";
- echo "<input type='hidden' name='forum' value='" . $_GET['forum'] . "'>";
- echo "Subject: <input type='text' style='width: 95%;' name='subject' /><br />";
- echo "<textarea style='width: 95%;' rows='10' name='content'></textarea><br />";
- echo "<input type='submit' name='newthread' value='Post' /><br />";
- echo "</form>";
- Catcher:
- if (isset($_POST['newthread'])) {
- $posted = date("Y-m-d H:i:s", time());
- $poster = getval("users", "id", "username", $_SESSION['user']);
- $post = $mysqli->real_escape_string(stripslashes($_POST['content']));
- $title = $mysqli->real_escape_string(stripslashes($_POST['subject']));
- echo "<!-- Variables: ";
- print_r($_POST);
- echo "-->";
- $result = $mysqli->query("INSERT INTO posts (content, posted, poster, forum) VALUES (" . $post . ", $posted, $poster, " . $_POST['forum'] . ")"); //Line 316
- $result2 = $mysqli->query("INSERT INTO threads (forum, title, posted, poster, views, posts, lastposttime) VALUES (" . $_POST['forum'] . ", " . $_POST['subject'] . ", $posted, $poster, 1, 0, $posted)");
- $thread = $mysqli->query("SELECT id FROM threads WHERE title='$title' AND forum=" . $_POST['forum'] . " AND posted=$posted AND poster=$poster")->fetch_row();
- $post = $mysqli->query("SELECT id FROM posts WHERE posted=$posted AND poster=" . $_SESSION['user'] . " AND forum=" . $_POST['forum'])->fetch_row();
- $result3 = $mysqli->query("UPDATE posts SET thread=" . $thread[0] . " WHERE id=" . $post[0]);
- if ($result && $result2 && $result3) {
- echo "Your post has been created.<br /><br />";
- $res = $mysqli->query("SELECT id FROM posts WHERE posted=$posted AND thread=" . $_POST['thread'] . " AND poster=$poster")->fetch_row();
- echo "<a href='forums.php?thread=" . $_POST['thread'] . "#post" . $res[0] . ">Click here</a> to go to your post.<br />";
- echo "<a href='forums.php?thread=" . $_POST['thread'] . ">Click here</a> to return to the previous thread.";
- } else {
- $mysqli->query("DELETE FROM posts WHERE posted=$posted AND poster=$poster AND forum=" . $_POST['forum']);
- $mysqli->query("DELETE FROM threads WHERE forum=" . $_POST['forum'] . " AND title=" . $_POST['subject'] . " AND posted=$posted AND poster=$poster");
- echo "Error creating post: " . $mysqli->error . "<br /><br />";
- echo "<a href='forums.php?thread=" . $_POST['thread'] . ">Click here</a> to return to the previous thread.";
- }
- }
- Output:
- Notice: Undefined index: forum in /home/tristan/Website/Instart/forums.php on line 316 Notice: Undefined index: forum in /home/tristan/Website/Instart/forums.php on line 317 Notice: Undefined index: forum in /home/tristan/Website/Instart/forums.php on line 318 Fatal error: Call to a member function fetch_row() on a non-object in /home/tristan/Website/Instart/forums.php on line 318
- Content of the comment (filled with a print_r):
- <!-- Variables: Array
- (
- [subject] => Next milestone.
- [content] => This is the first thread created through the website, rather than through the database.
- [newthread] => Post
- )
- -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement