Thursday, June 18, 2020

Update Images and content uysimh PHP mysqli

<?php
    include ('config.php');
$categoryid = $_REQUEST['Id'];
if(isset($_POST["user_submit"]))
{
    $name = $_REQUEST['name'];
   $email = $_REQUEST['email'];
   $phone = $_REQUEST['phone'];
   $visa_upload = $_REQUEST['visa_upload'];
   $visa_expiry = $_REQUEST['visa_expiry'];
   $license_upload = $_REQUEST['license_upload'];
   $licence_expiry = $_REQUEST['licence_expiry'];
   $passport_upload = $_REQUEST['passport_upload'];
   $passwport_expiry = $_REQUEST['passwport_expiry'];
 
    $rand = rand(0000,9999);
$filename = $_FILES['visa_upload']['name'];
$filetmpname = $_FILES['visa_upload']['tmp_name'];
$folder ='imagesuploadedf/';
move_uploaded_file($filetmpname, $folder.$filename);
  $timestamp = date("Y-m-d");
 


$filename1 =$_FILES['license_upload']['name'];
$filetmpname = $_FILES['license_upload']['tmp_name'];
$folder ='imagesuploadedf/';
move_uploaded_file($filetmpname, $folder.$filename1);


$filename2 = $_FILES['passport_upload']['name'];
$filetmpname = $_FILES['passport_upload']['tmp_name'];
$folder ='imagesuploadedf/';
move_uploaded_file($filetmpname, $folder.$filename2);

 $sql = "UPDATE driver_register SET name='$name',email='$email',phone='$phone',visa_expiry='$visa_expiry',licence_expiry='$licence_expiry',passwport_expiry='$passwport_expiry' WHERE Id = $categoryid";

  if ($conn->query($sql) === TRUE) {
   

 
   if($filename!='')
   {
      move_uploaded_file($filetmpname, $folder.$filename);
            $ww1 = mysqli_query($conn,"update driver_register set visa_upload='$filename' where Id ='$categoryid'");
   }
      if($filename1!='')
   {
      move_uploaded_file($filetmpname, $folder.$filename1);
            $ww2 = mysqli_query($conn,"update driver_register set license_upload='$filename1' where Id ='$categoryid'");
   }
      if($filename2!='')
   {
     move_uploaded_file($filetmpname, $folder.$filename2);
            $ww3 = mysqli_query($conn,"update driver_register set passport_upload='$filename2' where Id ='$categoryid'");
   }
   
   
    echo '<script>alert("Update Successfully.");window.location.assign("all_driver.php");</script>';
  }
  else{
      echo '<script>alert("please Update Again....");window.location.assign("all_driver.php?Id='.$categoryid.'");</script>';
  }
}


$query=mysqli_query($conn,"select * from driver_register where Id = '$categoryid' ") ;                   
  if(mysqli_num_rows($query)>0)
  {
   $res=mysqli_fetch_assoc($query);
   $name = $res['name'];
   $email = $res['email'];
   $phone = $res['phone'];
   $visa_upload = $res['visa_upload'];
   $visa_expiry = $res['visa_expiry'];
   $license_upload = $res['license_upload'];
   $licence_expiry = $res['licence_expiry'];
   $passport_upload = $res['passport_upload'];
   $passwport_expiry = $res['passwport_expiry'];
   
    $image= $res['image'];
  }
?>

No comments:

Post a Comment