Advertisement
Guest User

annya

a guest
May 19th, 2015
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.51 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include_once('admin/connection.php');
  4. include_once('functions.php');
  5. include_once('m_loginfunctions.php');
  6.  
  7. if(checkLoggedin())
  8. {
  9. $uemail = mysql_real_escape_string($_SESSION['user_sincere']);
  10. $upass = decode3t(mysql_real_escape_string($_SESSION['pass_sincere']));
  11. }
  12. else
  13. {
  14. header("Location: login.php");
  15. }
  16.  
  17. $str="";$str2="";
  18. $img_str="";$img_str2="";
  19. $regno="";$pid="";
  20. $phto0='';$phto1 ='';$phto2 ='';$phto3 ='';$phto4 ='';$phto5 ='';$phto6='';$phto7='';
  21. $thumb_img="";$thumb_report="";$image_to_be_cropped="";$thumb_full="";
  22.  
  23.  
  24. $selquery=mysql_query("select * from `pdetails` where `email`='$uemail' ") or die(mysql_error());
  25.  
  26. if(mysql_num_rows($selquery)==1)
  27. {
  28. $fet=mysql_fetch_array($selquery);
  29.  
  30. $regno=$fet['regno'];
  31. $pid = $fet['pid'];
  32. $phto0 = $fet['phto0'];
  33. $phto1 = $fet['phto1'];
  34. $phto2 = $fet['phto2'];
  35. $phto3 = $fet['phto3'];
  36. $phto4 = $fet['phto4'];
  37. $phto5 = $fet['phto5'];
  38. $phto6 = $fet['phto6'];
  39. $phto7 = $fet['phto7'];//kalyana kuri mage
  40.  
  41.  
  42. }
  43.  
  44. if( isset($_GET['phto']) && $_GET['phto']!='' )
  45. {
  46.       $phto = $_GET['phto'];
  47.      
  48.       switch($phto)
  49.       {
  50.        
  51.         case 0: $query ="update `pdetails` set `phto0`='' where `pid`='{$pid}' ";
  52.                 mysql_query($query);
  53.                   if(mysql_affected_rows()==1){
  54.                   unlink("admin/images/".$phto0);
  55.                   header("Location: photo.php");
  56.                   }//deleted
  57.                  
  58.                   break;
  59.                  
  60.         case 1: $query ="update `pdetails` set `phto1`='' where `pid`='{$pid}' ";
  61.                 mysql_query($query);
  62.                   if(mysql_affected_rows()==1){
  63.                   unlink("admin/images/".$phto1);
  64.                   header("Location: photo.php");
  65.                   }//deleted
  66.                  
  67.                   break;
  68.         case 2: $query ="update pdetails set phto2='' where pid='{$pid}' ";
  69.                 mysql_query($query);
  70.                   if(mysql_affected_rows()==1){
  71.                   unlink("admin/images/".$phto2);
  72.                   header("Location: photo.php");
  73.                   }//deleted
  74.                  
  75.                   break;
  76.         case 3: $query ="update pdetails set phto3='' where pid='{$pid}' ";
  77.                 mysql_query($query);
  78.                   if(mysql_affected_rows()==1){
  79.                   unlink("admin/images/".$phto3);
  80.                    header("Location: photo.php");
  81.                   }//deleted
  82.                  
  83.                   break;
  84.         case 4: $query ="update pdetails set phto4='' where pid='{$pid}' ";
  85.                 mysql_query($query);
  86.                   if(mysql_affected_rows()==1){
  87.                   unlink("admin/images/".$phto4);
  88.                    header("Location: photo.php");
  89.                   }//deleted
  90.                  
  91.                   break;
  92.         case 5: $query ="update pdetails set phto5='' where pid='{$pid}' ";
  93.                 mysql_query($query);
  94.                   if(mysql_affected_rows()==1){
  95.                   unlink("admin/images/".$phto5);
  96.                    header("Location: photo.php");
  97.                   }//deleted
  98.                  
  99.                   break;
  100.         case 6: $query ="update pdetails set phto6='' where pid='{$pid}' ";
  101.                 mysql_query($query);
  102.                   if(mysql_affected_rows()==1){
  103.                   unlink("admin/images/".$phto6);
  104.                    header("Location: photo.php");
  105.                   }//deleted
  106.                    
  107.                   break;
  108.        
  109.        
  110.         //kalyana kuri image
  111.         case 7: $query ="update pdetails set phto7='' where pid='{$pid}' ";
  112.                 mysql_query($query);
  113.                   if(mysql_affected_rows()==1){
  114.                   unlink("admin/images/".$phto7);
  115.                    header("Location: photo.php");
  116.                   }//deleted
  117.                    
  118.                   break;
  119.                  
  120.         default: //do nothing        
  121.       }//end switch
  122. }
  123.  
  124.  
  125.  
  126. //image upload portion
  127. for($i=0;$i<=7;$i++)
  128. {
  129.        
  130.     if(isset($_POST["add_phto$i"]) )
  131.     {
  132.    
  133.           if( $_FILES["phto$i"]["name"]=='' )
  134.           {
  135.               $img_str = 'Please select image for upload.' ;
  136.           }
  137.          
  138.           else if(
  139.                   (
  140.                    ($_FILES["phto$i"]["type"] == "image/gif") ||
  141.                    ($_FILES["phto$i"]["type"] == "image/jpeg")||
  142.                    ($_FILES["phto$i"]["type"] == "image/pjpeg")
  143.                    )
  144.                     &&
  145.                    ($_FILES["phto$i"]["size"] < 1048576)//means 1 mb 1024 bytes =1 Kb, 1024 Kb =1 mb
  146.                   )
  147.           {
  148.              
  149.                  if($_FILES["phto$i"]["error"]>0)
  150.                  {
  151.                     $img_str= "upload error(image $i)";
  152.                  }
  153.                  else
  154.                  {
  155.                         if($_FILES["phto$i"]["size"]!=0)
  156.                         {
  157.                           move_uploaded_file($_FILES["phto$i"]["tmp_name"],"admin/images/".$regno."_".$i.".jpg");
  158.                           $phto =$regno."_".$i.".jpg";
  159.                          
  160.                           $query = "update `pdetails` set `phto$i`='$phto' where `pid`='$pid' ";
  161.                           $resultset= mysql_query($query);
  162.                          
  163.                                 if(mysql_affected_rows()==1)
  164.                                 {
  165.                                     //$img_str2="Image uploaded successfully";
  166.                                     header("Location:photo.php");
  167.                                     exit;
  168.                                 }
  169.                           }
  170.                   }
  171.             }
  172.            
  173.             else
  174.             {
  175.                 $img_str= "(Image: $i) - Incompatible format or size exceeded 1 Mb.";
  176.             }
  177.  
  178.     }//end if
  179.    
  180. }//end for
  181.  
  182.  
  183.  
  184. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement