Jump to content

This is simple I know but I can't find it


Recommended Posts

Anybody know why I'm getting "Please fill in all fields" error? I put comments in to make it easier


<!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" xml:lang="en" lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Who's Missing?</title>
  <link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
  <h2>Someone Missing?</h2>

<?php
  require_once('appvars.php');
  require_once('connectvars.php');

  if (isset($_POST['submit'])) {
    // Grab the score data from the POST
    $name = $_POST['name'];
    $partner_name = $_POST['partner_name'];
$state = $_POST['state'];
    $photo = $_FILES['photo']['partner_name'];
    $photo_type = $_FILES['photo']['type'];
    $photo_size = $_FILES['photo']['size']; 

    if (!empty($name) && !empty($partner_name)
&& !empty($state) && !empty($photo)) {

if ((($photo_type == 'image/gif') || ($photo_type == 'image/jpeg') || ($photo_type == 'image/pjpeg') || ($photo_type == 'image/png'))
        && ($photo_size > 0) && ($photo_size <= GW_MAXFILESIZE)) {
        if ($_FILES['photo']['error'] == 0) {
// Move the file to temp
  $target = GW_UPLOADPATH . $photo;
  if (move_uploaded_file($_FILES['photo']['tmp_name'], $target)) {
// Connect to the database
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

// Write to the database
$query = "INSERT INTO guitarwars VALUES (0, NOW(), '$name', '$partner_name', '$state', '$photo')";
mysqli_query($dbc, $query);

// Confirm success with the user
echo '<p>Partner added. Enjoy!</p>';
echo '<p><strong>Name:</strong> ' . $name . '<br />';
echo '<strong>Partner:</strong> ' . $partner_name . '<br />';
echo '<strong>State:</strong> ' . $state . '<br />';
echo '<img src="' . GW_UPLOADPATH . $photo . '" alt="Score image" /></p>';
echo '<p><a href="guitar.php"><< Back to Partners page</a></p>';

// Clear the data to clear the form
            $name = "";
            $partner_name = "";
		$state = "";
            $photo = "";

            mysqli_close($dbc);
          }
          else {
echo '<p class="error">Sorry, there was a problem uploading your partners photo.</p>';
          }
        }
      }
else {
	echo '<p class="error">The photo must be a GIF, JPEG, or PNG image file no greater than ' . (GW_MAXFILESIZE / 320768) . ' MB in size.</p>';
      }
// delete the temporary photo image file
@unlink($_FILES['photo']['tmp_name']);
    }
    else {
      echo '<p class="error">Please fill in all fields.</p>';
    }
  }
?>

  <hr />
<form enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo GW_MAXFILESIZE; ?>" />
<label for="name">Name:</label>
<input type="text" id="name" name="name" value="<?php if (!empty($name)) echo $name; ?>" /><br />
<label for="partner">Partner:</label>
<input type="text" id="partner_name" name="partner_name" value="<?php if (!empty($partner_name)) echo $partner_name; ?>" /><br />
<label for="state">State:</label>
<input type="text" id="state" name="state" value="<?php if (!empty($state)) echo $state; ?>" /><br />
<label for="photo">Photo:</label>
<input type="file" id="photo" name="photo" />
    <hr />
<input type="submit" value="Add Partner" name="submit" />
  </form>
</body> 
</html>

Archived

This topic is now archived and is closed to further replies.

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