Jump to content

PHP Used to update database


steven21

Recommended Posts

Just looking at the update,

this should update

<?php
session_start();
error_reporting(E_ALL);
ini_set("display_errors", 1);
include('../functions.php');
echo dbconnect(); //Echo WTF ???
include ('logincheck.php'); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
  <head>
    <title>Fife Flyers - Admin Area</title>
    <link rel="stylesheet" type="text/css" href="style.css">
  </head>
  <body leftmargin=0 topmargin=0 marginheight="0" marginwidth="0" bgcolor="#ffffff">
    <table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
      <tr valign="top">
   <td width="50%" background="images/bg.gif"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
   <td valign="bottom" background="images/bg_left.gif"><img src="images/bg_left.gif" alt="" width="17" height="16" border="0"></td>
   <td>
     <table border="0" cellpadding="0" cellspacing="0" width="780" height="107">
       <tr valign="bottom">
         <td background="images/fon_top.gif"> </td>
         <td width="673" background="images/fon_top.gif">
      <table border="0" cellpadding="0" cellspacing="0" background="">
        <tr valign="bottom">
          <td>
            <!-- but act -->
            <table border="0" cellpadding="0" cellspacing="0">
         <tr valign="bottom">
           <td><img src="images/b_left_a.gif" width="9" height="37" alt="" border="0"></td>
           <td background="images/b_fon_a.gif"><p class="menu01"><a href="index2.php">ADMIN  </a></p></td>
           <td><img src="images/b_right_a.gif" width="9" height="37" alt="" border="0"></td>
         </tr>
            </table>
            <!-- /but act -->
          </td>
        </tr>
      </table>
         </td>
       </tr>
     </table>
     <table border="0" cellpadding="0" cellspacing="0" width="780" height="107">
       <tr valign="top">
         <td bgcolor="#E7BD1D"><table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
          <td bgcolor="#E7BD1D"><table width="100%" border="0" cellspacing="0" cellpadding="0">
         <tr>
           <td> </td>
         </tr>
            </table></td>
        </tr>
      </table>
      <div align="center"></div>
      <div align="center"><img src="images/title01.gif" width="183" height="35" alt="" border="0"></div>
       <nobr class="right">
         <div style="padding-top: 10px; padding-left: 20px;"><span class="right"><?php echo("<form action=\"auth.php\" method=\"post\" name=\"login\" id=\"login\">
                                      Username: <input name=\"PHP_AUTH_USER\" type=\"text\" id=\"PHP_AUTH_USER\" value=\"username\"><br><br>
                    Password: <input name=\"PHP_AUTH_PW\" type=\"password\" id=\"PHP_AUTH_PW\" value=\"\"><br>
                    <input type=\"submit\" name=\"Submit\" value=\"Login\">

                  </form>"); ?></span></div>
       </nobr>
         <p class="left"> </p>
         <br>
         <br>
         </td>
         <td rowspan="2">
      <div align="center"><img src="images/top01.gif" width="597" height="24" alt="" border="0"></div>
      <table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
          <td> </td>
          <td>
            <p style="color: #1F269D; font-size: 20px; margin-left: 0px;"><b>Edit  Player Stats:</b></p>
            <p style="color: #1F269D; font-size: 20px; margin-left: 0px;"><span style="color: #1F269D; font-size: 16px; margin-left: 0px;">Powerplay Goals & Shorthanded Goals are not to be added to points total - all goals scored should be added to goals column and these are added to total points. </span></p>
            <?php
            if( isset($_SESSION['msg']) ) echo  $_SESSION['msg'];
    if (isset($_REQUEST['act'])) {
      $act = $_REQUEST['act'];
    }
    if (isset($_REQUEST['stat'])) {
      $stat = $_REQUEST['stat'];
    }

    if ($stat==1) {
      // normal players
      $table = "players";
    } else {
      // snl_players
      $table ="snl_players";
    }

    switch($act){
      case "editdo":
	$query = "UPDATE `$table`
	    SET `Nationality` = '{$_POST['Nationality']}',
	    `GamesPO` = '{$_POST['GamesPO']}',
	    `AssistsPO` = '{$_POST['AssistsPO']}',
	    `GoalsPO` = '{$_POST['GoalsPO']}',
	    `PPGoalsPO` = '{$_POST['PPGoalsPO']}',
	    `SHGoalsPO` = '{$_POST['SHGoalsPO']}',
	    `PointsPO` = '{$_POST['PointsPO']}',
	    `PIMPO` = '{$_POST['PIMPO']}' ,
	    `PIM` = '{$_POST['PIM']}' ,
	    `PointsCup` = '{$_POST['PointsCup']}' ,
	    `PIMCup` = '{$_POST['PIMCup']}' ,
	    `AssistsCup` = '{$_POST['AssistsCup']}' ,
	    `GoalsCup` = '{$_POST['GoalsCup']}' ,
	    `PPGoalsCup` = '{$_POST['PPGoalsCup']}' ,
	    `SHGoalsCup` = '{$_POST['SHGoalsCup']}' ,
	    `GamesCup` = '{$_POST['GamesCup']}' ,
	    `Points` = '{$_POST['Points']}' ,
	    `Assists` = '{$_POST['Assists']}' ,
	    `Goals` = '{$_POST['Goals']}' ,
	    `PPGoals` = '{$_POST['PPGoals']}' ,
	    `SHGoals` = '{$_POST['SHGoals']}' ,
	    `TeamID` = '{$_POST['TeamID']}' ,
	    `Player` = '{$_POST['Player']}' ,
	    `Games` = '{$_POST['Games' ]}'
	    WHERE `PlayerID` = '{$_GET['PlayerID']}'";
	$result = mysql_query($query) or die (mysql_error());
	$_SESSION['msg'] = "The player has been updated. No. of records updated, ". mysql_affected_rows();
	echo ("The player has been updated. No. of records updated, ".mysql_affected_rows()."<br><br><a href=\"playerstats.php\"> Go back to the player List</a>");
	break;
    }

            if (strcmp($act, 'edit')==0) {
      $query11 = "SELECT * FROM `$table` WHERE `PlayerID` = '$PlayerID'";
      $result11 = mysql_query($query11) or die (mysql_error());
      $rows = mysql_fetch_array($result11);
      $PlayerID = $rows['PlayerID'];
      $TeamID = $rows['TeamID'];
      $Team = $rows['Team'];
      $Player = $rows['Player'];
      $Games = $rows['Games'];
      $Goals = $rows['Goals'];
      $PPGoals = $rows['PPGoals'];
      $SHGoals = $rows['SHGoals'];
      $Assists = $rows['Assists'];
      $PIM = $rows['PIM'];
      $Points = $rows['Points'];
      $GamesCup = $rows['GamesCup'];
      $GoalsCup = $rows['GoalsCup'];
      $PPGoalsCup = $rows['PPGoalsCup'];
      $SHGoalsCup = $rows['SHGoalsCup'];
      $AssistsCup = $rows['AssistsCup'];
      $PIMCup = $rows['PIMCup'];
      $PointsCup = $rows['PointsCup'];
      /* $GamesNPL = $rows['GamesNPL'];
      $GoalsNPL = $rows['GoalsNPL'];
      $PPGoalsNPL = $rows['PPGoalsNPL'];
      $SHGoalsNPL = $rows['SHGoalsNPL'];
      $AssistsNPL = $rows['AssistsNPL'];
      $PIMNPL = $rows['PIMNPL'];
      $PointsNPL = $rows['PointsNPL']; */
      $GamesPO = $rows['GamesPO'];
      $GoalsPO = $rows['GoalsPO'];
      $PPGoalsPO = $rows['PPGoalsPO'];
      $SHGoalsPO = $rows['SHGoalsPO'];
      $AssistsPO = $rows['AssistsPO'];
      $PIMPO = $rows['PIMPO'];
      $PointsPO = $rows['PointsPO'];
      $Nationality = $rows['Nationality'];

      $query11 = "SELECT * FROM `teams` WHERE `TeamID` = '$TeamID'";
      $result11 = mysql_query($query11) or die (mysql_error());
      $rows = mysql_fetch_array($result11);
      $TeamName = $rows['TeamName'];


      echo ("<form name=\"form1\" method=\"post\" action=\"playerstats.php?act=edit&PlayerID=$PlayerID&stat=$stat\">
	<table width=\"80%\" border=\"0\">
	  <tr>
	    <td width=\"30%\" class=\"data\">Player Name </td>
	    <td width=\"70%\"><input name=\"Player\" type=\"text\" id=\"Player\" value=\"$Player\"></td>
	  </tr>
	  <tr>
	    <td class=\"data\">Associated Team ID </td>
	    <td class=\"data\">  <select name=\"TeamID\">");

      $query11 = "SELECT * FROM `teams`";
      $result11 = mysql_query($query11) or die (mysql_error());
      while ( $rows = mysql_fetch_array($result11) ) {
	$TeamName = $rows['TeamName'];
	$TeamID2 = $rows['TeamID'];
	if (strcmp($TeamID,$TeamID2)==0) {
	  echo("    <option value=\"$TeamID2\" selected>$TeamName</option>");
	} else {
	  echo("    <option value=\"$TeamID2\">$TeamName</option>");
	}
      }

      echo("</select></td>
	  </tr>
	  <tr>
	    <td class=\"data\">Games</td>
	    <td><input name=\"Games\" type=\"text\" id=\"Games\" size=\"6\" value=\"$Games\"></td>
	  </tr>
	  <tr>
	    <td class=\"data\">Goals</td>
	    <td><input name=\"Goals\" type=\"text\" id=\"Goals\" size=\"6\" value=\"$Goals\"></td>
	  </tr>    <tr>
	    <td class=\"data\">PPGoals</td>
	    <td><input name=\"PPGoals\" type=\"text\" id=\"Goals\" size=\"6\" value=\"$PPGoals\"></td>
	  </tr>    <tr>
	    <td class=\"data\">SHGoals</td>
	    <td><input name=\"SHGoals\" type=\"text\" id=\"Goals\" size=\"6\" value=\"$SHGoals\"></td>
	  </tr>
	  <tr>
	    <td class=\"data\">Assists</td>
	    <td><input name=\"Assists\" type=\"text\" id=\"Assists\" size=\"6\" value=\"$Assists\"></td>
	  </tr>
	  <tr>
	    <td class=\"data\">PIM</td>
	    <td><input name=\"PIM\" type=\"text\" id=\"PIM\" size=\"6\" value=\"$PIM\"></td>
	  </tr>
	  <tr>
	    <td class=\"data\">Points</td>
	    <td><input name=\"Points\" type=\"text\" id=\"Points\" size=\"6\" value=\"$Points\"></td>
	  </tr>
	  <tr>
	    <td class=\"data\">GamesCup</td>
	    <td><input name=\"GamesCup\" type=\"text\" id=\"GamesCup\" size=\"6\" value=\"$GamesCup\"></td>
	  </tr>  <tr>
	    <td class=\"data\">GoalsCup</td>
	    <td><input name=\"GoalsCup\" type=\"text\" id=\"GoalsCup\" size=\"6\" value=\"$GoalsCup\"></td>
	  </tr>
	  <tr>
	    <td class=\"data\">PPGoalsCup</td>
	    <td><input name=\"PPGoalsCup\" type=\"text\" id=\"GoalsCup\" size=\"6\" value=\"$PPGoalsCup\"></td>
	  </tr><tr>
	    <td class=\"data\">SHGoalsCup</td>
	    <td><input name=\"SHGoalsCup\" type=\"text\" id=\"GoalsCup\" size=\"6\" value=\"$SHGoalsCup\"></td>
	  </tr>
	  <tr>
	    <td class=\"data\">AssistsCup</td>
	    <td><input name=\"AssistsCup\" type=\"text\" id=\"AssistsCup\" size=\"6\" value=\"$AssistsCup\"></td>
	  </tr>
	  <tr>
	    <td class=\"data\">PIMCup</td>
	    <td><input name=\"PIMCup\" type=\"text\" id=\"PIMCup\" size=\"6\" value=\"$PIMCup\"></td>
	  </tr>
	  <tr>
	    <td class=\"data\">PointsCup</td>
	    <td><input name=\"PointsCup\" type=\"text\" id=\"PointsCup\" size=\"6\" value=\"$PointsCup\"></td>
	  </tr>  ");

      if ($stat!=1) {
	echo("
      <tr><td class=\"data\">GamesPO</td>
	    <td><input name=\"GamesPO\" type=\"text\" id=\"GamesPO\" size=\"6\" value=\"$GamesPO\"></td>
	  </tr> <tr>
	    <td class=\"data\">GoalsPO</td>
	    <td><input name=\"GoalsPO\" type=\"text\" id=\"GoalsPO\" size=\"6\" value=\"$GoalsPO\"></td>
	  </tr>
      <tr>
	    <td class=\"data\">PPGoalsPO</td>
	    <td><input name=\"PPGoalsPO\" type=\"text\" id=\"GoalsPO\" size=\"6\" value=\"$PPGoalsPO\"></td>
	  </tr>
      <tr>




	    <td class=\"data\">SHGoalsPO</td>
	    <td><input name=\"SHGoalsPO\" type=\"text\" id=\"GoalsPO\" size=\"6\" value=\"$SHGoalsPO\"></td>
	  </tr><tr>




	    <td class=\"data\">AssistsPO</td>
	    <td><input name=\"AssistsPO\" type=\"text\" id=\"AssistsPO\" size=\"6\" value=\"$AssistsPO\"></td>
	  </tr><tr>




	    <td class=\"data\">PIMPO</td>
	    <td><input name=\"PIMPO\" type=\"text\" id=\"PIMPO\" size=\"6\" value=\"$PIMPO\"></td>
	  </tr><tr>




	    <td class=\"data\">PointsPO</td>
	    <td><input name=\"PointsPO\" type=\"text\" id=\"PointsPO\" size=\"6\" value=\"$PointsPO\"></td>
	  </tr><tr>




	    <td class=\"data\">Nationality</td>
	    <td><input name=\"Nationality\" type=\"text\" id=\"Nationality\" value=\"$Nationality\"></td>
	  </tr>



      <td class=\"data\"> </td>
	    <td> </td>
	  </tr>
	  <tr>
	    <td class=\"data\"> </td>
	    <td><input type=\"submit\" name=\"Submit\" value=\"Edit\"></td>
	  </tr>
	</table>
      </form>");
      }
            } elseif (strcmp($act,'teamlist')==0) {
      $query112 = "SELECT * FROM `teams` WHERE `TeamID` = '$TeamID'";
      $result112 = mysql_query($query112) or  die (mysql_error());
      $rows2 = mysql_fetch_array($result112);
      $TeamName = $rows2['TeamName'];
      $Logo = $rows2['Logo'];

      if ($Logo!="") {
	echo("<img src=\"../Images/$Logo\" /><br><br>");
      }
      echo ("<strong>Edit $TeamName Players</strong><br><br>Click Player Names to edit details<br><br>");
      $query11 = "SELECT * FROM `players` WHERE `TeamID` = '$TeamID'";
      $result11 = mysql_query($query11) or  die (mysql_error());
      while ( $rows = mysql_fetch_array($result11) ) {
	$Player = $rows['Player'];
	$PlayerID = $rows['PlayerID'];
	$TeamID = $rows['TeamID'];
	echo ("<span class=\"style1\"><a href=\"playerstats.php?act=edit&PlayerID=$PlayerID&stat=1\">$Player</a><br>");
      }
            } else {
     echo ("Click Team Names to view players<br><br>");
     $query11 = "SELECT distinct TeamID FROM `players` ORDER BY `TeamID`";
     $result11 = mysql_query($query11) or    die (mysql_error());
     $TeamID_in = "";
     while ( $rows = mysql_fetch_array($result11) ) {
       //$TeamID = $rows['TeamID'];
       $TeamID_in .= "'".$rows['TeamID']."',";
     }
     $TeamID_in = (substr($TeamID_in,-1) == ",") ? substr($TeamID_in, 0, -1) : $TeamID_in;

     //  $query112 = "SELECT * FROM `teams` WHERE `TeamID` = '$TeamID'";
     $query112 = "SELECT * FROM `teams` WHERE `TeamID` IN ($TeamID_in)";
     $result112 = mysql_query($query112) or  die (mysql_error());
     $rows2 = mysql_fetch_array($result112);
     $TeamName = $rows2['TeamName'];
     echo ("<span class=\"style1\"><a href=\"playerstats.php?act=teamlist&TeamID=$TeamID&stat=1\">$TeamName</a><br>");
            }
            echo ("<a name=\"snl\"></a><br><strong><a href=\"snlplayerstats.php\">SNL Teams</a></strong><br><br>");
    ?>

            <p> </p>
            <p> </p>
            <p>
         <label>  </label>
            </p>
            <p>
         <label></label>
            </p>
            <p></p>
            <p> </p>
            <p> </p>
            <p><a href=""></a></p>   </td>
        </tr>
      </table>
      <div align="center"><img src="images/hr01.gif" width="556" height="11" alt="" border="0"></div>    </td>
         </tr>
         <tr valign="bottom" bgcolor="#D0E0ED">
      <td bgcolor="#E7BD1D"><img src="images/bot_left.gif" width="183" height="21" alt="" border="0"></td>
         </tr>
     </table>
     <table border="0" cellpadding="0" cellspacing="0" width="780" height="64" background="images/fon_bot.gif">
       <tr valign="top">
         <td>
      <table border="0" cellpadding="0" cellspacing="0" width="780" background="">
        <tr>
          <td width="300"><p class="menu02">Designed by Steven McLean</p></td>
          <td>
            <p class="menu02"><a href="">FifeFlyers.co.uk Admin Home</a></p>
          </td>
        </tr>
      </table>
         </td>
       </tr>
     </table>
   </td>
   <td valign="bottom" background="images/bg_right.gif"><img src="images/bg_right.gif" alt="" width="17" height="16" border="0"></td>
   <td width="50%" background="images/bg.gif"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
      </tr>
    </table>

  </body>
</html>

I fixed a few random bugs as well *untested*

 

But it needs re-working

Link to comment
Share on other sites

Now getting

 

Notice: A session had already been started - ignoring session_start() in C:\Domains\fifeflyers.co.uk\wwwroot\admin\logincheck.php on line 1

 

Notice: Use of undefined constant icehock - assumed 'icehock' in C:\Domains\fifeflyers.co.uk\wwwroot\admin\logincheck.php on line 8

 

and

 

Notice: Undefined variable: stat in C:\Domains\fifeflyers.co.uk\wwwroot\admin\snlplayerstats.php on line 84

 

Notice: Undefined variable: act in C:\Domains\fifeflyers.co.uk\wwwroot\admin\snlplayerstats.php on line 93

 

Notice: Undefined variable: act in C:\Domains\fifeflyers.co.uk\wwwroot\admin\snlplayerstats.php on line 126

 

Notice: Undefined variable: act in C:\Domains\fifeflyers.co.uk\wwwroot\admin\snlplayerstats.php on line 308

Click Team Names to view players

 

 

Notice: Undefined variable: TeamID in C:\Domains\fifeflyers.co.uk\wwwroot\admin\snlplayerstats.php on line 343

Link to comment
Share on other sites

you shouldn't get

Notice: Undefined variable: act 

as you stated

As I am editing the stats on the playerstats page the PHP action at the top shows:

 

playerstats.php?act=edit&PlayerID=1

 

After I click on the edit button to update the database it goes to:

 

playerstats.php?act=editdo&PlayerID=1&stat=

 

But it is taking me back to a list of the teams (when I click on each team it shows me their players that I can edit)

 

change

if (isset($_REQUEST['act'])) {
         $act = $_REQUEST['act'];
       }
       if (isset($_REQUEST['stat'])) {
         $stat = $_REQUEST['stat'];
       }

to

 

it won't update until you pass act=editdo

if (isset($_REQUEST['act'])) {
         $act = $_REQUEST['act'];
       }else{
          $act = ""; //Default whatever!
       }
       if (isset($_REQUEST['stat'])) {
         $stat = $_REQUEST['stat'];
       }else{
          $stat = 0;
       }

Link to comment
Share on other sites

Ok, I am not getting any error messages but what is happening now is that I am getting into the Edit Player Stats page then I can click on the league (which should then show all the teams). But when I am clicking on the league it is not showing up the different teams but instead just staying on the page with the league name

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.