Jump to content

Recommended Posts

Hello Everyone!

I am having trouble putting the pledge_class variable into my ap_uploads table.  I am not sure why.  Any assistance on this matter would be greatly appreciated.

 

<?php

session_name ('YourVisitID');
session_start(); // Start the session.

// If no session value is present, redirect the user.
if (!isset($_SESSION['user_id'])) {

// Start defining the URL.
$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
// Check for a trailing slash.
if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
	$url = substr ($url, 0, -1); // Chop off the slash.
}
$url .= '/index.php'; // Add the page.
header("Location: $url");
exit(); // Quit the script.
}

$page_title = 'Upload Awards or Paddles';
include('./includes/header.html');

$counter = 1;

if(isset($_POST['submitted'])) {

require_once('./includes/mysql_connect.php');


for($i = 0; $i < $counter; $i++) {

$filename = 'upload' . $i;
$description = 'description' . $i;

if(isset($_FILES[$filename]) && ($_FILES[$filename]['error'] !=4)) {

	if(!empty($_POST[$description])) {
		$d = "'" . escape_data($_POST[$description]) . "'";

		} else {

		$d = 'NULL';

		}

	$query = "INSERT INTO ap_uploads (pledge_class, file_name, file_size, file_type, description) VALUES (pledge_class, '{$_FILES[$filename]['name']}', '{$_FILES[$filename]['size']}', '{$_FILES[$filename]['type']}', $d)";
	$result = mysql_query ($query);

if($result) {

$upload_id = mysql_insert_id();

if(move_uploaded_file($_FILES[$filename]['tmp_name'], "awards_paddles_img/$upload_id")) {

		echo '<p>File number ' . ($i + 1) . ' has been uploaded!</p>';

		} else {

		echo '<p><font color="red">File number ' . ($i +1) . 'could not be moved.</font></p>';

		$query = "DELETE FROM ap_uploads WHERE upload_id = $upload_id";
		$result = mysql_query($query);

		}

	} else {

		echo '<p><font color="red"> Your submission could not be processed due to a system error.</font></p>';

	}
}
}

mysql_close();

}
?>

<form enctype="multipart/form-data" action="upload_ap_images.php" method="post">

<fieldset><legend>Fill out the form to upload the image:</legend>
<input type="hidden" name="MAX_FILE_SIZE" value="524288" />

<br />

<p><b>Please Make Sure That There Are No Spaces In The File Name.</b></p>  <p>For Example, the filename picture 1.jpeg is not correct.  The filename picture1.jpeg or picture_1.jpeg is correct.</p>

<br />


<?php
for ($i = 0; $i < $counter; $i++) {

?><p>Pledge Class:<?php
  // Make the pledge class array.
$pledgeclass = array (1 => 'FF', 'Alpha', 'Beta', 'Gamma', 'Delta', 'Epsilon', 'Zeta', 'Eta', 'Theta', 'Iota', 'Kappa', 'Lambda', 'Mu', 'Nu', 'Xi', 'Omicron', 'Pi', 'Rho', 'Sigma', 'Tau', 'Upsilon', 'Phi', 'Chi', 'Psi', 'Omega');

// Make the pledge class pull-down menu.
echo '<select name="pledge_class">';

echo "<option value=\"\">Select Pledge Class</option>\n";
foreach ($pledgeclass as $key => $value) {

echo "<option value=\"$value\">$value</option>\n";
}
echo '</select>';
?></p><?php


echo ' <p><b>File:</b> <input type="file" name="upload' . $i . '" /></p>
       <p><b>Description:</b><br /> <textarea name="description' . $i . '" cols="40" rows="5"></textarea></p><br />
	   ';
	   }
	   
?>

</fieldset>
<input type="hidden" name="submitted" value="TRUE" />
<div align="center"><input type="submit" name="submit" value="Upload Images" /></div>

</form>

<?php
include ('./includes/footer.html');
?>

 

to be honest, I think the problem i due to the fact that the pledge_class variable is not being properly defined so that it can be entered into the table with this query.  I need help with that.  Everything else works 100% perfectly, but this pull down menu value is not being inserted into the table. 

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.