hello
I have a section in my website, where people can upload photos. the gallery is divied into different categories. I modified the original script so people can add a photo from anywhere in the website (before they had to go a certain category and then upload a photo to that certain category).

The script I added looks if a category is not selected so shows the drop down menu, and when a category is selected it adds a hidden input which contains the category number in order to add it for the database.

My problem is that the drop down menu is not working, every time I add a photo I check the database to find that the category number is 0. On the other hand the hidden input is working perfectly, where it adds the right number of the category.

The variable for the category is catno which is the same name for the drop down menu, so where is the mistake that I am missing?

Below is the script that I am using for the upload of the photos:

<?php

if (RUN_MODULE !== true)
{
    die ("<center><h3>You can not access the file directly</h3></center>");
}

include("modules/gallery/config.php");
include("modules/gallery/functions.php");

$member_group = $apt->cookie['cgroup'];

$member_id = $apt->format_data($apt->cookie['cid']);
$member_ip   = $apt->ip;

$allow_me = in_array($member_group,$allow_upload);
if(!$allow_me){
$apt->errmsg("you can not upload photos");
}else{

$allow_ext = array('.gif','.png','.jpg');
$allow_types = array('image/jpeg', 'image/jpg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif');

//================================================================
$submit  = $apt->post['submit'];

if($submit)
{
$imgtitle 	= $apt->format_data(trim($apt->post["imgtitle"]));
$imgdesc 	= $apt->format_data(trim($apt->post["imgdesc"]));
 if($apt->cookie['cid']==0 or $apt->cookie['cid']== $apt->Guestid)
 {
$member_un	= $apt->format_data(trim($apt->post["guest_un"]));
$usermail 	= $apt->post["usermail"];
if (!$apt->check_email($usermail)){
$apt->errmsg(LANG_ERROR_VALID_EMIAL);
}
}else{
$member_un   = $apt->format_data($apt->cookie['cname']);
}

$catno 	= $apt->post["catno"];
$file 	= $apt->files["cfile"]["tmp_name"];
$realname 	= $apt->files["cfile"]["name"];
$type 	= $apt->files["cfile"]["type"];
$size 	= $apt->files["cfile"]["size"];
$ext  	= strrchr($realname,'.');
$size = $size / 1024;
$ext  = strtolower($ext);
$time = time();
$uploaded = $time . $ext;
$allow_e = in_array($ext,$allow_ext);
$allow_t = in_array($type,$allow_types);

if(!$allow_e){
$apt->errmsg("These file extensions are not allowed");
}elseif(!$allow_t){
$apt->errmsg("These file extensions are not allowed");
}elseif($size > $size_limit){
$apt->errmsg("Too big file");
}elseif(is_file("modules/gallery/photos/$uploaded")){
$apt->errmsg("This photo has been uploaded before");
}else{
if(@is_uploaded_file($file)){
$do = @move_uploaded_file($file,"modules/gallery/photos/$uploaded");}
if($do){
$thefile = "modules/gallery/photos/$uploaded";
if($ext=='.gif'){
$image = ImageCreateFromGIF($thefile);
}elseif($ext=='.png'){
$image = ImageCreateFromPNG($thefile);
}else{
$image = ImageCreateFromJPEG($thefile);
}
$width = imagesx($image) ;
$height = imagesy($image) ;

$new_width = $thumb_width; 
$new_height = ($new_width * $height) / $width ;

if (function_exists('ImagecreateTrueColor'))
{
$thumb = ImageCreateTrueColor($new_width,$new_height);
ImageCopyResampled($thumb,$image,0,0,0,0,$new_width,$new_height,$width,$height);
}
else
{
$thumb = ImageCreate($new_width,$new_height);
ImageCopyResized($thumb,$image,0,0,0,0,$new_width,$new_height,$width,$height);
}
ImageJPEG($thumb, 'modules/gallery/thumb/'.$uploaded);
imagedestroy($image);
$i++;

if($parent_eye == 1){
$allow = 0;
if($member_group == 1){$allow = 1;}
$apt->query("INSERT INTO rafia_gallery_image VALUES ('', '$catno', '$imgtitle', '$imgdesc', '$uploaded', '0', '0','$member_un', '$member_id','$member_ip','$usermail','0','0','$time','$allow');");
$imgid = $apt->insertid();
}else{
$allow = 1;
$apt->query("INSERT INTO rafia_gallery_image VALUES ('', '$catno', '$imgtitle', '$imgdesc', '$uploaded', '0', '0','$member_un', '$member_id','$member_ip','$usermail','0','0','$time','$allow');");
$imgid = $apt->insertid();
}

if($allow == 1){
$apt->query("Update rafia_gallery_cat set gcount=gcount+1 where gid='$catno'");
$url = "mod.php?mod=gallery&modfile=picshow&imgid=$imgid";
$apt->bodymsg("You will be redirected to the photo",$url);
}else{
$url = "mod.php?mod=gallery&modfile=category&cat=$catno";
$apt->bodymsg("Your photo has been sent for verification",$url);
}

}else{
echo "<div align=center><center><table border='0' width='80%' bgcolor='#EBEBEB'>
<tr><td width='100%' align='center'><br><font class=fontablt> There is an error <br>
<center>[ <a href='javascript:history.go(-1);'>Go Back</a> ]</center>
<br></td></tr></table></center></div>";
}
}

}else{
	if(isset($apt->get['cat']))
       $cat 	= $apt->setid("cat");

$index_middle = $apt->table_cat_module("<a href=mod.php?mod=$mod_name>&nbsp;$mod_title</a>");
eval("\$index_middle .= \" " . $apt->getmodtemplate ( 'gallery_header', $modid,$mod_theme ) . "\";");

$size_limit = intval($size_limit*1024);
if($size_limit >= 1048576){
        $size_limit = round($size_limit / 1048576 * 100) / 100 . " MB ";
}
elseif($size_limit >= 1024){
        $size_limit = round($size_limit / 1024 * 100) / 100 . "KB ";
}
$page_icon ='';


if($member_group == 3){
	$guest_options = "<tr>
							<td align='center' class='stars'>*</td>
							<td class='red_bold'>name</td>
							<td>
							<b>
							<input dir=ltr type='text' name='guest_un' size='35' class='imglib_input_textbox'></b></td>
						</tr>
	<tr>
							<td align='center' class='stars'>*</td>
							<td class='red_bold'>Email :</td>
							<td>
							<b>
							<input dir=ltr type='text' name='usermail' size='35' class='imglib_input_textbox'></b></td>
						</tr>";

$star = '*';
}else{$star = ' ';}
            
			if(!isset($apt->get['cat']))
            {
				$catchoose = "<tr><td align='center' class='stars'>*</td>";
				$catchoose .= "<td class='red_bold'>Choose category: </td>";
                $catchoose .= "<td align=right width=\"100%\"><select name='catno'>";
             $result = $apt->query("select * from rafia_gallery_cat order by gid");
                  while($row=$apt->dbarray($result))
          {
			  @extract($row);
            $catchoose .=  "<option value='$gid'>$gtitle</option>";
          }
          $catchoose .=  "</select></td></tr>\n";
            }else{
			$catchoose = "<input type=\"hidden\" name=\"catno\" value=\"$gid\">";
		}
			

eval("\$index_middle .= \" " . $apt->getmodtemplate ( 'gallery_add_image', $modid,$mod_theme ) . "\";");

eval("\$index_middle .= \" " . $apt->getmodtemplate ( 'gallery_footer', $modid,$mod_theme ) . "\";");

echo $index_middle;
}
}
?>

hai there..
i have some arrow
i used map and i want to know how the way if we click the
the map can range to symbol direction. thanks before..

hii

i have 2 drp down listbox in my form.....where in one list box i had fetch a col's value..& now i want that when we select the value from that list box ..[suppose the value is cake] then i want in my secon list box the types of that value to be displayed another tables[which the types of cake..]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.