mysql - PHP not properly inserting into the database -


i'm converting code extremely long statements (is correct word?) separate files each page. code i'm show worked fine before moved it's own file.

the page's full code is:

    <?     require_once('./inc/glob_head.php');      $database->openconnection();      $listofgamesquery = $database->querydb("select * mainsite_games");      if (isset($_get) && $_get['action'] == 'deletegame')      {         $gameid = $_get['gameid'];         $database->querydb("delete mainsite_games id='$gameid'");         redir('viewgames.php');     }     elseif (isset($_get) && $_get['action'] == 'editgame')     {         $gameid = $_get['gameid'];         $gamenameqry = $database->querydb("select gamename mainsite_games id='$gameid'");         while ($gamenamedta = $database->fetcharray($gamenameqry))         {              $gamename = $gamenamedta['gamename'];         }          $gamedescqry = $database->querydb("select gamedesc mainsite_games id='$gameid'");          while ($gamedescdta = $database->fetcharray($gamedescqry))         {              $gamedesc = $gamedescdta['gamedesc'];         }     ?>     <form name="editgame" id="editgame" action="viewgames.php?action=processedit&gameid=<? echo $gameid; ?>" method="post">         <input type="text" name="gamename" value="<? echo stripslashes($gamename); ?>" /><br />         <textarea name="gamedesc" class="span12" rows="10"><? echo stripslashes($gamedesc); ?></textarea><br />         <input type="submit" name="submiteditgame" class="btn btn-primary" />     </form>     <?     }     elseif (isset($_get) && $_get['action'] == 'processedit')     {         $gameid = $_get['gameid'];         $gamename = $database->escapestring($_post['gamename']);          $gamedesc = $database->escapestring($_post['gamedesc']);          $database->querydb("update mainsite_games set gamename='$gamename' id='$gameid'");          $database->querydb("update mainsite_games set gamedesc='$gamedesc' id='$gameid'");          redir('viewgames.php');      } else {                     echo '<div class="contcont">';                         echo '<table>';                             echo '<thead>';                                 echo '<tr>';                                     echo '<th>game name</th>';                                     echo '<th>delete</th>';                                     echo '<th>edit</th>';                                 echo '</tr>';                             echo '</thead>';                             echo '<tbody>';                                 while ($listofgames = $database->fetchassoc($listofgamesquery)) {                                     echo '<tr>';                                         print '<td>' . stripslashes($listofgames['gamename']) . '</td>';                                         print '<td><a href="viewgames.php?action=deletegame&gameid='.$listofgames['id'].'">delete</a></td>';                                         print '<td><a href="viewgames.php?action=editgame&gameid='.$listofgames['id'].'">edit</a></td>';                                     echo '</tr>';                                 }                             echo '</tbody>';                         echo '</table>';                      echo '</div>';                 echo '</div>';             echo '</div>';         echo '</body>';     echo '</html>'; } $database->closeconnection(); ?> 

glob_head provides database class, database connection, functions file requirement, , styling/page structure constant around site. having stated this, $database calls not mistakes, , defined elsewhere.

now problem is, in above code, editgame elseif block pulls information database successfully, therefore assume must getting information correctly. now, when user clicks submit, it'll take them next block, processedit, , reason makes fields blank , sets blank values in database. have no idea what's going on. maybe needs fresh set of eyes? in advance.

for reference, 'redir' calls custom function uses javascript redirection instead of relying on headers. find cleaner, , possibly easier use changing structure of code.

you submitting method="post" looking @ $_get superglobal variable. $_get variable empty, because there no submission being made.

change instances of $_get $_request (or $_post), or change method="post" "method="get".


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -