Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For some reason this is not working and i am unable to click the submit button <

ID: 3577087 • Letter: F

Question

For some reason this is not working and i am unable to click the submit button

<?php # Script 9.7 - updatetable.php
// This page lets the user update table

$page_title = 'Update table';
include ('includes/a9header.html');

// Check for form submission:
if ($_SERVER['REQUEST_METHOD'] == 'POST') {

require ('a9mysqli_connect.php'); // Connect to the db.
  
$errors = array(); // Initialize an error array.}

if (empty($_POST['teamid'])) {
  $errors[] = 'You forgot to enter the team id.';
} else {
  $ti = mysqli_real_escape_string($dbc, trim($_POST['teamid']));
}

// Check for a team name:
if (empty($_POST['team'])) {
  $errors[] = 'You forgot to enter the team.';
} else {
  $t = mysqli_real_escape_string($dbc, trim($_POST['team']));
}

// Check for pennants:
if (empty($_POST['pennants'])) {
  $errors[] = 'You forgot to enter the Pennants to be updated';
} else {
  $p = mysqli_real_escape_string($dbc, trim($_POST['pennants']));

// Check for a new password and match
if (empty($_POST['world'])) {
  $errors[] = 'You forgot to enter the world series to be updated';
} else {
  $w = mysqli_real_escape_string($dbc, trim($_POST['world']));
}

if (empty($errors)) { // If everything's OK.

  // Check that they've entered the right email address/password combination:
  $q = "SELECT ts.team, ch.team_id,ch.pennants, ch.worldseries from champs ch JOIN teamstats ts ON ts.team_id= ch.team_id WHERE (ch.team_id=$ti and ts.team='$t');";
  $r = @mysqli_query($dbc, $q);
  $num = @mysqli_num_rows($r);
  if ($num == 1) { // Match was made.

   // Get the user_id:
   $row = mysqli_fetch_array($r, MYSQLI_NUM);

   // Make the UPDATE query:
   $q = "UPDATE champs SET pennats=('$p'), worldseries=('$w') WHERE teamid=('$ti');";  
   $r = @mysqli_query($dbc, $q);
   
   if (mysqli_affected_rows($dbc) == 1) { // If it ran OK.

    // Print a message.
    echo '<h1>Thank you!</h1>
    <p>The Pennants and World Series have been updated!</p><p><br /></p>';

   } else { // If it did not run OK.

    // Public message:
    echo '<h1>System Error</h1>
    <p class="error">The Pennants and World Series could not be changed due to a system error. We apologize for any inconvenience</p>';

    // Debugging message:
    echo '<p>' . mysqli_error($dbc) . '<br /><br />Query: ' . $q . '</p>';

   }

   mysqli_close($dbc); // Close the database connection.

   // Include the footer and quit the script (to not show the form).
   include ('includes/footer.html');
   exit();
    
  } else { // Invalid combination.
   echo '<h1>Error!</h1>
   <p class="error">The values you entered do not match those on file.</p>';
  }
  
} else { // Report the errors.

  echo '<h1>Error!</h1>
  <p class="error">The following error(s) occurred:<br />';
  foreach ($errors as $msg) { // Print each error.
   echo " - $msg<br /> ";
  }
  echo '</p><p>Please try again.</p><p><br /></p>';

} // End of if (empty($errors)) IF.

mysqli_close($dbc); // Close the database connection.
  
  }} // End of the main Submit conditional.
?>
<h1>Update table</h1>
<form action="a9update.php" method="post">
<p>Team ID: <input type="text" name="teamid" size="20" maxlength="60" value="<?php if (isset($_POST['teamid'])) echo $_POST['teamid']; ?>" /> </p>
<p>Team Name: <input type="text" name="team" size="10" maxlength="50" value="<?php if (isset($_POST['team'])) echo $_POST['team']; ?>" /></p>
<p>Pennants <input type="text" name="pennants" size="10" maxlength="20" value="<?php if (isset($_POST['pennants'])) echo $_POST['pennants']; ?>" /></p>
<p>World Series <input type="text" name="world" size="10" maxlength="20" value="<?php if (isset($_POST['world'])) echo $_POST['world']; ?>" /></p>
<p><input type="submit" name="submit" value"Update" /></p>
</form>
<?php include ('includes/footer.html'); ?>

Explanation / Answer

The code is working fine. Plese make sure that all the files which are included are in the correct folder.