Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- include_once('admin/connection.php');
- include_once('functions.php');
- include_once('m_loginfunctions.php');
- if(checkLoggedin())
- {
- $uemail = mysql_real_escape_string($_SESSION['user_sincere']);
- $upass = decode3t(mysql_real_escape_string($_SESSION['pass_sincere']));
- }
- else
- {
- header("Location: login.php");
- }
- $str="";$str2="";
- $img_str="";$img_str2="";
- $regno="";$pid="";
- $phto0='';$phto1 ='';$phto2 ='';$phto3 ='';$phto4 ='';$phto5 ='';$phto6='';$phto7='';
- $thumb_img="";$thumb_report="";$image_to_be_cropped="";$thumb_full="";
- $selquery=mysql_query("select * from `pdetails` where `email`='$uemail' ") or die(mysql_error());
- if(mysql_num_rows($selquery)==1)
- {
- $fet=mysql_fetch_array($selquery);
- $regno=$fet['regno'];
- $pid = $fet['pid'];
- $phto0 = $fet['phto0'];
- $phto1 = $fet['phto1'];
- $phto2 = $fet['phto2'];
- $phto3 = $fet['phto3'];
- $phto4 = $fet['phto4'];
- $phto5 = $fet['phto5'];
- $phto6 = $fet['phto6'];
- $phto7 = $fet['phto7'];//kalyana kuri mage
- }
- if( isset($_GET['phto']) && $_GET['phto']!='' )
- {
- $phto = $_GET['phto'];
- switch($phto)
- {
- case 0: $query ="update `pdetails` set `phto0`='' where `pid`='{$pid}' ";
- mysql_query($query);
- if(mysql_affected_rows()==1){
- unlink("admin/images/".$phto0);
- header("Location: photo.php");
- }//deleted
- break;
- case 1: $query ="update `pdetails` set `phto1`='' where `pid`='{$pid}' ";
- mysql_query($query);
- if(mysql_affected_rows()==1){
- unlink("admin/images/".$phto1);
- header("Location: photo.php");
- }//deleted
- break;
- case 2: $query ="update pdetails set phto2='' where pid='{$pid}' ";
- mysql_query($query);
- if(mysql_affected_rows()==1){
- unlink("admin/images/".$phto2);
- header("Location: photo.php");
- }//deleted
- break;
- case 3: $query ="update pdetails set phto3='' where pid='{$pid}' ";
- mysql_query($query);
- if(mysql_affected_rows()==1){
- unlink("admin/images/".$phto3);
- header("Location: photo.php");
- }//deleted
- break;
- case 4: $query ="update pdetails set phto4='' where pid='{$pid}' ";
- mysql_query($query);
- if(mysql_affected_rows()==1){
- unlink("admin/images/".$phto4);
- header("Location: photo.php");
- }//deleted
- break;
- case 5: $query ="update pdetails set phto5='' where pid='{$pid}' ";
- mysql_query($query);
- if(mysql_affected_rows()==1){
- unlink("admin/images/".$phto5);
- header("Location: photo.php");
- }//deleted
- break;
- case 6: $query ="update pdetails set phto6='' where pid='{$pid}' ";
- mysql_query($query);
- if(mysql_affected_rows()==1){
- unlink("admin/images/".$phto6);
- header("Location: photo.php");
- }//deleted
- break;
- //kalyana kuri image
- case 7: $query ="update pdetails set phto7='' where pid='{$pid}' ";
- mysql_query($query);
- if(mysql_affected_rows()==1){
- unlink("admin/images/".$phto7);
- header("Location: photo.php");
- }//deleted
- break;
- default: //do nothing
- }//end switch
- }
- //image upload portion
- for($i=0;$i<=7;$i++)
- {
- if(isset($_POST["add_phto$i"]) )
- {
- if( $_FILES["phto$i"]["name"]=='' )
- {
- $img_str = 'Please select image for upload.' ;
- }
- else if(
- (
- ($_FILES["phto$i"]["type"] == "image/gif") ||
- ($_FILES["phto$i"]["type"] == "image/jpeg")||
- ($_FILES["phto$i"]["type"] == "image/pjpeg")
- )
- &&
- ($_FILES["phto$i"]["size"] < 1048576)//means 1 mb 1024 bytes =1 Kb, 1024 Kb =1 mb
- )
- {
- if($_FILES["phto$i"]["error"]>0)
- {
- $img_str= "upload error(image $i)";
- }
- else
- {
- if($_FILES["phto$i"]["size"]!=0)
- {
- move_uploaded_file($_FILES["phto$i"]["tmp_name"],"admin/images/".$regno."_".$i.".jpg");
- $phto =$regno."_".$i.".jpg";
- $query = "update `pdetails` set `phto$i`='$phto' where `pid`='$pid' ";
- $resultset= mysql_query($query);
- if(mysql_affected_rows()==1)
- {
- //$img_str2="Image uploaded successfully";
- header("Location:photo.php");
- exit;
- }
- }
- }
- }
- else
- {
- $img_str= "(Image: $i) - Incompatible format or size exceeded 1 Mb.";
- }
- }//end if
- }//end for
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement