($upload_dir) doesn't exist");
}
//check if the directory is writable.
if (!is_writeable("$upload_dir")){
die ("The directory ($upload_dir) is NOT writable.");
}
// ----------------------------------------------------------------------
if (is_uploaded_file($_FILES['file_1']['tmp_name']))
{ $size = $_FILES['file_1']['size'];
if ($size > $size_bytes)
{ echo "File Too Large. Please try again.";exit();}
$filename = $_FILES['file_1']['name'];
if(file_exists($upload_dir.$filename))
{ echo "Oops! The file named $filename already exists";exit();}
if (move_uploaded_file($_FILES['file_1']['tmp_name'],$upload_dir.$filename)) {
echo "
File ($filename) uploaded!.";
chmod("$upload_dir$filename", 0744);
$strSQL = "insert into files (fname, grant_id, date) values ('$filename', $grant_id, '$date')";
$result=mysql_query($strSQL);
if ( !$result ){
echo "Error Writting to Database Webmaster";
}
}
else
{echo "There was a problem moving your file";exit();}
// successful upload of the file
$error_occured = "no";
}
else{echo "file_1 was not give a file
";}
// ---------------------------------------------------------------------------------
if (is_uploaded_file($_FILES['file_2']['tmp_name']))
{ $size = $_FILES['file_2']['size'];
if ($size > $size_bytes)
{ echo "File Too Large. Please try again.";exit();}
$filename = $_FILES['file_2']['name'];
if(file_exists($upload_dir.$filename))
{ echo "Oops! The file named $filename already exists";exit();}
if (move_uploaded_file($_FILES['file_2']['tmp_name'],$upload_dir.$filename)) {
echo "
File ($filename) uploaded!.";
chmod("$upload_dir$filename", 0744);
$strSQL = "insert into files (fname, grant_id, date) values ('$filename', $grant_id, '$date')";
$result=mysql_query($strSQL);
if ( !$result ){
echo "Error Writting to Database Webmaster";
}
}
else
{echo "There was a problem moving your file";exit();}
// successful upload of the file
$error_occured = "no";
}
else{echo "file_2 was not give a file
";}
// ---------------------------------------------------------------------------------
if (is_uploaded_file($_FILES['file_3']['tmp_name']))
{ $size = $_FILES['file_3']['size'];
if ($size > $size_bytes)
{ echo "File Too Large. Please try again.";exit();}
$filename = $_FILES['file_3']['name'];
if(file_exists($upload_dir.$filename))
{ echo "Oops! The file named $filename already exists";exit();}
if (move_uploaded_file($_FILES['file_3']['tmp_name'],$upload_dir.$filename)) {
echo "
File ($filename) uploaded!.";
chmod("$upload_dir$filename", 0744);
$strSQL = "insert into files (fname, grant_id, date) values ('$filename', $grant_id, '$date')";
$result=mysql_query($strSQL);
if ( !$result ){
echo "Error Writting to Database Webmaster";
}
}
else
{echo "There was a problem moving your file";exit();}
// successful upload of the file
$error_occured = "no";
}
else{echo "file_3 was not give a file
";}
// ---------------------------------------------------------------------------------
if (is_uploaded_file($_FILES['file_4']['tmp_name']))
{ $size = $_FILES['file_4']['size'];
if ($size > $size_bytes)
{ echo "File Too Large. Please try again.";exit();}
$filename = $_FILES['file_4']['name'];
if(file_exists($upload_dir.$filename))
{ echo "Oops! The file named $filename already exists";exit();}
if (move_uploaded_file($_FILES['file_4']['tmp_name'],$upload_dir.$filename)) {
echo "
File ($filename) uploaded!.";
chmod("$upload_dir$filename", 0744);
$strSQL = "insert into files (fname, grant_id, date) values ('$filename', $grant_id, '$date')";
$result=mysql_query($strSQL);
if ( !$result ){
echo "Error Writting to Database Webmaster";
}
}
else
{echo "There was a problem moving your file";exit();}
// successful upload of the file
$error_occured = "no";
}
else{echo "file_4 was not give a file
";}
// ---------------------------------------------------------------------------------
if (is_uploaded_file($_FILES['file_5']['tmp_name']))
{ $size = $_FILES['file_5']['size'];
if ($size > $size_bytes)
{ echo "File Too Large. Please try again.";exit();}
$filename = $_FILES['file_5']['name'];
if(file_exists($upload_dir.$filename))
{ echo "Oops! The file named $filename already exists";exit();}
if (move_uploaded_file($_FILES['file_5']['tmp_name'],$upload_dir.$filename)) {
echo "
File ($filename) uploaded!.";
chmod("$upload_dir$filename", 0744);
$strSQL = "insert into files (fname, grant_id, date) values ('$filename', $id, '$date')";
$result=mysql_query($strSQL);
if ( !$result ){
echo "Error Writting to Database Webmaster";
}
}
else
{echo "There was a problem moving your file";exit();}
// successful upload of the file
$error_occured = "no";
}
else{echo "file_5 was not give a file
";}
// ----------------------------------------------------------------------
//$strSQL="SELECT * FROM attribute_types order by id";
//$result=mysql_query($strSQL);
//$num_entries=mysql_num_rows($result);
$strSQL="SELECT * FROM attribute_values WHERE grant_id=$grant_id order by type_id";
$result=mysql_query($strSQL);
$num_entries=mysql_num_rows($result);
//for($i=0; $i<$num_entries_values; $i++){
// $type = mysql_result($result_values, $i, "type");
// $value[$i] = $_POST["$type"];
//echo $i." - ".$type." - ".$_POST["$type"]."
";
//}
$field_names = array_keys($_POST);
// updating the attributes_values table -------------------
for($i=0; $i<$num_entries; $i++){
$new_value ="***";
$value_old = "***";
$post_name = $field_names[$i+1];
$new_value = $_POST[$post_name];
echo "$post_name == $new_value
";
$value_old = mysql_result($result, $i, "value");
$type_id = mysql_result($result, $i, "type_id");
if($type_id == "3"){ $new_value = Markdown($new_value);}
$new_value = str_replace("'", " ", $new_value);
$strSQL_update = "update attribute_values set value='$new_value' where (grant_id = $grant_id and type_id=".($type_id)." and value='$value_old')";
echo $strSQL_update."
";
$result_update=mysql_query($strSQL_update);
if($result_update){ echo "- grants table updated successfully.
";}
else{
$error_occured = "yes";
echo "error - ".$strSQL_update."
";
}
}
// got the base information now get any additional information
$add_type_1 = $_POST['additional_attribute_1'];
$add_type_2 = $_POST['additional_attribute_2'];
$add_type_3 = $_POST['additional_attribute_3'];
$add_type_4 = $_POST['additional_attribute_4'];
$add_type_5 = $_POST['additional_attribute_5'];
$add_value_1 = $_POST['additional_value_1'];
$add_value_2 = $_POST['additional_value_2'];
$add_value_3 = $_POST['additional_value_3'];
$add_value_4 = $_POST['additional_value_4'];
$add_value_5 = $_POST['additional_value_5'];
if($add_value_1 != null){
$strSQL="SELECT * FROM attribute_types where type='$add_type_1'";
$result=mysql_query($strSQL);
$type_id = mysql_result($result, 0, "id");
$strSQL = "insert into attribute_values(value, grant_id, type_id) values ('$add_value_1', $grant_id, $type_id)";
//echo $strSQL."
";
$result=mysql_query($strSQL);
}
if($add_value_2 != null){
$strSQL="SELECT * FROM attribute_types where type='$add_type_2'";
$result=mysql_query($strSQL);
$type_id = mysql_result($result, 0, "id");
$strSQL = "insert into attribute_values(value, grant_id, type_id) values ('$add_value_2', $grant_id, $type_id)";
//echo $strSQL."
";
$result=mysql_query($strSQL);
}
if($add_value_3 != null){
$strSQL="SELECT * FROM attribute_types where type='$add_type_3'";
$result=mysql_query($strSQL);
$type_id = mysql_result($result, 0, "id");
$strSQL = "insert into attribute_values(value, grant_id, type_id) values ('$add_value_3', $grant_id, $type_id)";
$result=mysql_query($strSQL);
}
if($add_value_4 != null){
$strSQL="SELECT * FROM attribute_types where type='$add_type_4'";
$result=mysql_query($strSQL);
$type_id = mysql_result($result, 0, "id");
$strSQL = "insert into attribute_values(value, grant_id, type_id) values ('$add_value_4', $grant_id, $type_id)";
//echo $strSQL."
";
$result=mysql_query($strSQL);
}
if($add_value_5 != null){
$strSQL="SELECT * FROM attribute_types where type='$add_type_5'";
$result=mysql_query($strSQL);
$type_id = mysql_result($result, 0, "id");
$strSQL = "insert into attribute_values(value, grant_id, type_id) values ('$add_value_5', $grant_id, $type_id)";
//echo $strSQL."
";
$result=mysql_query($strSQL);
}
/**
echo "
";
*/
echo "link to entry";
?>