Jump to content

Bldg a FORUM - the FORM doesn't display - WHY?


Scotty13

Recommended Posts

Trying to build a forum.  My two Tables that I built for this forum are good.

 

When I test in my browsers?

I click on a topic from my index.php

It goes to section.php?id=36 (script below)

If I click on my type="submit" value="Take Off With A Different Conversation" button.

I get this ?ERROR: You do not exist in the system.?  from new_topic.php (script below).

I?m following some tuts online and watched them over and over and its just not working, could you PLEASE HELP ME!

 

Sorry for all the script, but I didnt want to leave anything out.

 

_________________________________________________________________________________________ section.php __________________________________________

  <?php

  session_start();

  include_once ("../wi_class_files/agoTimeFormat.php");

  $myAgoObject = new convertToAgo;

  include_once "../scripts/connect_to_mysql.php"; // Connect to the database

  // Get the section ID from the url variable coming in

  if (isset($_GET['id']) && $_GET['id'] != "") {

  $sid = preg_replace('#[^0-9]#i', '', $_GET['id']); // filter all characters except numbers for security

  } else {

  echo "ERROR: Variables to run this script have been removed from the URL.";

  exit();

  }

  // Query the database for that section id, make sure it exists and get the section title

  $sql = mysql_query("SELECT * FROM forum_sections WHERE id='$sid' LIMIT 1");

  $numRows = mysql_num_rows($sql);

  if ($numRows < 1) {

  echo "ERROR: That section does not exist you have tampered with our URLs.";

  exit();

  }

  while($row = mysql_fetch_array($sql)){

  $sectionTitle = $row["title"];

  }

  // Use the section ID to query the "forum_posts" table in the database to get all the threads for this section

  $sql = mysql_query("SELECT * FROM forum_posts WHERE type='a' AND section_id='$sid' ORDER BY date_time DESC LIMIT 25");

  $dynamicList = "";

  $numRows = mysql_num_rows($sql);

  if ($numRows < 1) {

  $dynamicList = "There are no threads in this section yet. You can be the first to post.";

  } else {

  while($row = mysql_fetch_array($sql)){

  $thread_id = $row["id"];

  $post_author = $row["post_author"];

  $post_author_id = $row["post_author_id"];

  $date_time = $row["date_time"];

  $convertedTime = ($myAgoObject -> convert_datetime($date_time));

  $whenPost = ($myAgoObject -> makeAgo($convertedTime));

  $thread_title = $row["thread_title"];

  $dynamicList .= '<img src="style/threadPic.jpg" width="26" height="18" alt="Topic" /> ' . $post_author . ' - <a href="view_thread.php?id=' .

 

$thread_id . '">' . $thread_title . '</a> - ' . $whenPost . '<br />';

  }

  }

  ?>

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  <html xmlns="http://www.w3.org/1999/xhtml">

  <head>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  <link href="style/style.css" rel="stylesheet" type="text/css" />

  <link rel="icon" href="favicon.ico" type="image/x-icon" />

  <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />

  <title><?php echo $sectionTitle; ?> Work & Trip Forum</title>

  <meta name="Keywords" content="Funny, work, coworker, work, today, wow, forum, airline, blog, announcing, announcer, announced, announce, blog, blogging, blogger,

 

travel, tips, heard, tips, suggestions, nightmares, anniversary, retirement, birthday, party, heard, rumor, chat, gossip" />

  </head>

  <body>

  <div align="center">

<?php include_once("template_header.php"); ?>

  </div>

 

  <table style="background-color: #FFFFFF; border:#069 1px solid; border-top:none;" width="900" border="0" align="center" cellpadding="12" cellspacing="0">

<tr>

  <td width="731" valign="top">

  <div id="breadcrumbs"><a href="http://www.**********.com">Return Home: **********</a> ← <a

 

href="http://************.com/root/forum/index.php">Return: Work & Trip Topics</a></div>

  <h1 style="margin-left:12px;"><?php echo $sectionTitle; ?> </h1>

<form action="new_topic.php" method="post">

<input name="forum_id" type="hidden" value="<?php echo $sid; ?>" />

<input name="forum_title" type="hidden" value="<?php echo $sectionTitle; ?>" />

<input name="myBtn1" type="submit" value="Take Off With A Different Conversation" style="font-size:16px; padding:8px;" />

  </form>

<br /><br />

<div style="margin-left:12px; font-size:14px; line-height:1.5em;"><?php echo $dynamicList; ?></div>

  <br /><br /><br /></td>

<td width="189" valign="top"><div style=" width:160px; height:600px; background-color: #F0F0F0; color: #CCC; padding:12px;"> <br />

<br />

 

_________________________________________________________________________________________ new_topic.php _____________________________________

 

  <?php

  session_start();

  include_once "../scripts/connect_to_mysql.php"; // Connect to the database

  // Check to see if the user is logged in with session variables

  if (!isset($_SESSION['userloca']) || $_SESSION['userloca'] == "") {

  echo "You'll need to check in first before you can post anything on your Work & Trip Forum.";

  exit();

  } else {

  // Assume they are a tktedmembers because they have a locator session variable set

  // Check the database to be sure that their ID, locator, and email session variables all match in the database

  $u_id = mysql_real_escape_string($_SESSION['id']);

  $u_name = mysql_real_escape_string($_SESSION['username']);

  $u_email = mysql_real_escape_string($_SESSION['useremail']);

  $u_loca = mysql_real_escape_string($_SESSION['userloca']);

  $sql = mysql_query("SELECT * FROM myMembers WHERE id='$u_id' AND username='$u_name' AND email='$u_email' AND locator='$u_loca'");

  $numRows = mysql_num_rows($sql);

  if ($numRows < 1) {

echo "ERROR: You do not exist in the system.";

  exit();

  }

 

  }

 

 

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

/////////////////////////////

  // Check to make sure the URL variables of "sid" and "title" are set

  if (!isset($_POST['forum_id']) || $_POST['forum_id'] == "" || !isset($_POST['forum_title']) || $_POST['forum_title'] == "") {

  echo "Important variables are missing";

  exit();

 

  } else {

  // Acquire the variables and proceed to show them a form for creating a new topic

  $forum_section_id = preg_replace('#[^0-9]#i', '', $_POST['forum_id']);

  $forum_section_title = preg_replace('#[^A-Za-z 0-9]#i', '', $_POST['forum_title']);

  }

 

  ///////////////////////////////////////////////////////////////////////////////////////////////////

 

  $sql = mysql_query("SELECT * FROM forum_sections WHERE id='$forum_section_id' AND title='$forum_section_title'");

  $numRows = mysql_num_rows($sql);

  if ($numRows < 1) {

  echo "ERROR: That section does not exist.";

  exit();

 

  }

  ?>

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  <html xmlns="http://www.w3.org/1999/xhtml">

  <head>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  <link href="style/style.css" rel="stylesheet" type="text/css" />

  <title><?php echo $sectionTitle; ?>Work & Trip Forum</title>

  <script type="text/javascript" language="javascript">

  <!--

  function validateMyForm ( ) {

  var isValid = true;

  if ( document.form1.post_title.value == "" ) {

  alert ( "Please type in a title for this topic" );

  isValid = false;

  } else if ( document.form1.post_title.value.length < 10 ) {

  alert ( "Your title must be at least 10 characters long" );

  isValid = false;

  } else if ( document.form1.post_body.value == "" ) {

  alert ( "Please type in your topic body." );

  isValid = false;

  }

  return isValid;

  }

  //-->

  </script>

  </head>

  <body>

  <?php include_once("template_header.php"); ?>

  <table style="background-color: #F0F0F0; border:#069 1px solid; border-top:none;" width="900" border="0" align="center" cellpadding="12" cellspacing="0">

<tr>

  <td width="666" valign="top">

  <div id="breadcrumbs"><a href="http://www.**********.com">Return Home: **********</a> ← <a

 

href="http://***********.com/root/forum/index.php">Return: Work & Trip Forum</a> ← <a href="section.php?id=<?php echo $forum_section_id; ?>"><?php echo

 

$forum_section_title; ?></a></div>

  <h2>Creating a new topic in the <em><?php echo $forum_section_title; ?></em>Work & Trip Form</h2>

  <form action="parse_post.php" method="post" name="form1">

  <input name="post_type" type="hidden" value="a" />

  Announcer:<br /><input name="topic_author" type="text" disabled="disabled" maxlength="64" style="width:96%;" value="<?php echo $u_name; ?>" />

  <br /><br />

  Announcement Title:<br /><input name="post_title" type="text" maxlength="64" style="width:96%;" /><br /><br />

  Tell Us What Happen Today... <span class="smtext">  (Use only fictitious names if describing a passenger)

  </span><br />

  <br />

  Please type in your topic body:<br /><textarea name="post_body" rows="15" style="width:96%;"></textarea>

  <br /><br /><input name="" type="submit" value="Post Announcement!" onclick="javascript:return validateMyForm();"/>

  <input name="fsID" type="hidden" value="<?php echo $forum_section_id; ?>" />

  <input name="fsTitle" type="hidden" value="<?php echo $forum_section_title; ?>" />

  <input name="uid" type="hidden" value="<?php echo $_SESSION['id']; ?>" />

  <input name="uloca" type="hidden" value="<?php echo $_SESSION['userloca']; ?>" />

  </form>

 

________________________________________________________________________________________________________________________________________________

 

Scotty13

 

Link to comment
Share on other sites

You need to find out why:

$u_id = mysql_real_escape_string($_SESSION['id']);
     $u_name = mysql_real_escape_string($_SESSION['username']);
     $u_email = mysql_real_escape_string($_SESSION['useremail']);
     $u_loca = mysql_real_escape_string($_SESSION['userloca']);
     $sql = mysql_query("SELECT * FROM myMembers WHERE id='$u_id' AND username='$u_name' AND email='$u_email' AND locator='$u_loca'");
     $numRows = mysql_num_rows($sql);
     if ($numRows < 1) {
       echo "ERROR: You do not exist in the system.";
        exit();
     }

This database query doesn't work.  Try looking at your session variables, and finding why they do not match what is in the database.

echo '<pre>' . print_r($_SESSION,true) . '</pre>';

 

Additionally, please put your code inside of the [ code ] ... [ /code ] blocks provided, they make reading it much easier.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.