troubleshooting Question

HTTP_POST_VARS not being set?

Avatar of Oldiesmann
Oldiesmann asked on
PHPWeb Languages and Standards
9 Comments1 Solution280 ViewsLast Modified:
I have been trying to figure this out for several days now... I have this thing created that allows users to select "moods" by clicking on an image, and I want the board administrators to be able to re-order/rename the moods, but it won't work. Here's the basic info:

Each mood has 4 values associated with it: an Auto-incrementing ID, a name, a filename and an order ID, which defaults to 0.

Below is the section of the code that loads the table info to show the values for the mood and allow the person to change them ($db_prefix is a global variable set in another file, $cgi is "/index.php?board=", $imagesdir is a reference to the location of the image files for the board, and all the text variables are also set in another file). The form loads everything just fine, but when I click on submit, it doesn't update the changes, and I did some testing and found that it wasn't setting the $HTTP_POST_VARS values in the second function:

      $get_moods = mysql_query("SELECT * FROM {$db_prefix}moods WHERE id='$id' ORDER BY oid ASC");
      echo '
      <form action="' . $cgi . ';action=modifymoods" method="POST">
      <table border="1" width="100%" cellspacing="0" cellpadding="0" bgcolor="' . $color['bordercolor'] . '" class="bordercolor" align="center">
      <tr>
            <td valign="middle" align="left" class="titlebg" bgcolor="' . $color['titlebg'] . '" colspan="5" height=22><img src="' . $imagesdir . '/grin.gif" /></td>
            <td valign="middle" align="center" class="titlebg" bgcolor="' . $color['titlebg'] . '" colspan="5" height=22><b><font size="2" class="text1" color="' . $color['titletext'] . '">' . $moodtxt[8] . '</font></b></td>
      </tr></table>
      <table border="0" width="100%" cellspacing="1" cellpadding="1" bgcolor="' . $color['bordercolor'] . '" class="bordercolor" align="center">
      <tr>
            <td class="catbg" bgcolor="' . $color['catbg'] . '" width="30%" align="center">' . $moodtxt['6']. '</td>
            <td class="catbg" bgcolor="' . $color['catbg'] . '" width="30%" align="center">' . $moodtxt['7'] . '</td>
            <td class="catbg" bgcolor="' . $color['catbg'] . '" width="30%" align="center">' . $moodtxt['13'] . '</td>
            <td class="catbg" bgcolor="' . $color['catbg'] . '" width="30%" align="center">Mood Image</td>
            <td class="catbg" bgcolor="' . $color['catbg'] . '" width="10%" align="center"></td>
      </tr>';

      $i = 1;
      while ($mood = mysql_fetch_assoc($get_moods)) {
            echo '
            <tr>
                  <td class="windowbg" bgcolor="' . $color['windowbg'] . '" width="30%" align="center"><input type="text" name="name$i" value="' . $mood[name] . '"></td>
                  <td class="windowbg" bgcolor="' . $color['windowbg'] . '" width="30%" align="center"><input type="text" name="fn$i" value="' . $mood[filename] . '"></td>
                  <td class="windowbg" bgcolor="' . $color['windowbg'] . '" width="30%" align="center"><input type="text" name="oid$i" value="' . $mood[oid] . '"></td>
                  <td class="windowbg" bgcolor="' . $color['windowbg'] . '" width="30%" align="center"><img src="' . $imagesdir . '/' . $mood[filename] . '" alt="' . $mood[name] . '">';
                  
                  if ($MenuType == 1) { echo' <td class="windowbg" bgcolor="' . $color['windowbg'] . '" width="10%" align="center"><a href="index.php?action=deletemood&id=' . $mood[id] . '">' . $moodtxt['14'] . '</a></td>';}
                  else { echo' <td class="windowbg" bgcolor="' . $color['windowbg'] . '" width="10%" align="center"><a href="index.php?action=deletemood&id=' . $mood[id] . '"><img src="' . $imagesdir . '/delete.gif" border=0 /></a></td>'; }
            echo'</tr>';
            $i++;
            }
      echo '
      <tr>
            <td class="catbg" bgcolor="' . $color['catbg'] . '" align="center" colspan="5"><input type="submit" value="Modify Moods"><br /></td>
      </tr>
      </table>
      </form>';
      footer();
    obExit();
}</pre>

function ModifyMoods2() {
      global $db_prefix, $HTTP_POST_VARS, $fn, $name, $oid, $id, $sourcedir;      

      $i = 1;
      $get_moods = mysql_query("SELECT * FROM {$db_prefix}moods WHERE id='$id' ORDER BY oid ASC");

      while ($mood = mysql_fetch_assoc($get_moods)) {
            if (isset($HTTP_POST_VARS["name$i"])) {
                  if (isset($HTTP_POST_VARS["fn$i"])) {
                        if (isset($HTTP_POST_VARS["oid$i"])) {
                              $name = $HTTP_POST_VARS["name$i"];
                              $fn = $HTTP_POST_VARS["fn$i"];
                              $oid = $HTTP_POST_VARS["oid$i"];
                              
                              $result = mysql_query("
                                                UPDATE {$db_prefix}moods
                                                SET name='$name', filename='$fn', oid='$oid'
                                                WHERE (id='$id')");
                              
                              if (!$result) { echo(mysql_error()); }
                              }
                        }
                  }
            $i++;
            }
      include_once("$sourcedir/Admin.php");
      Admin();
      }

Any ideas as to why this isn't working?
ASKER CERTIFIED SOLUTION
joaocmreis

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros