Jump to content

[SOLVED] Simple Forum Code not working


shelyshely

Recommended Posts

:( I have a very simple php forum I created through a class I took with Sessions.edu about a year ago.  It never really worked right then but I'm trying to use it now on our Family Reunion page.  My main issue is when you reply to someones post it shows as if they posted the response even though someone else is logged in.  My url is http://www.cavazosfamilyreunion.com/forum.htm.  I will gladly submit my code to anyone that can help me.
Link to comment
https://forums.phpfreaks.com/topic/126744-solved-simple-forum-code-not-working/
Share on other sites

I don't know which page to post, I have:

 

show_topic

reply_in_topic

add_topic

show_forum

 

Here is my code for reply_in_topic:

 

<?php

session_start();

 

if (!isset($_SESSION[id])) {

    header("Location: login.php");

    exit;

}

 

if ($_POST[op] != "ds") {

if ((!isset($_GET[f])) || (!isset($_GET[t]))) {

  header("Location: forums.php");

  exit;

}

 

$display_block = "

  <form method=POST action=\"$_SERVER[php_SELF]\">

  <p><strong>Post Text:</strong><br>

  <textarea name=\"post_text\" rows=8 cols=40

  wrap=virtual></textarea>

  <input type=\"hidden\" name=\"forum_id\" value=\"$_GET[f]\">

  <input type=\"hidden\" name=\"topic_id\" value=\"$_GET[t]\">

  <input type=\"hidden\" name=\"op\" value=\"ds\">

  <p><input type=submit name=\"submit\" value=\"Submit Form\"></p>

  </form>";

 

} else {

  foreach ($_POST as $form_var) {

    if (trim($form_var) == "") {

    header("Location: reply_to_post.php?t=$_GET[t]");

    exit;

  }

}

 

 

$conn = mysql_connect("xxxxxxxxx", "xxxxx", "xxxxxxx") or die(mysql_error());

mysql_select_db("xxxxx",$conn) or die(mysql_error());

   

  $add_post = "INSERT INTO forum_posts VALUES ('', '$_POST[topic_id]', '$_POST[forum_id]', '$_POST[post_text]', '$_SESSION[id]', now())";

  mysql_query($add_post, $conn) or die(mysql_error());

 

  header("Location: show_topic.php?topic_id=$topic_id");

  exit;

  }

?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.