Upload Banyak Gambar Secara Bersamaan Menggunakan PHP MySQL

Selamat siang kali ini kami akan mencoba membahas bagaimana mengupload banyak gambar secara bersamaan menggunakan PHP MySQL, pada pembuatan aplikasi sederhana ini kami menggunakan PHP:PDO.

Aplikasi ini sangat bermanfaat ketika kalian igin mengupload gambar yang banyak secara bersamaan kedalam database, biasa aplikasi seperti ini banyak digunakan di perkantoran dan di institusi pendidikan yang kadang memerlukan banyak form untuk mengupload gambar yang banyak.

Ada beberapa yang harus dipersiapkan di antaranya adalah kalan harus terlebih dahulu membuat folder dengan nama vehicleimages folder ini adalah tempat penyimpanan file gambar yang di upload.

Berikutnya buat database dengan nama carrental, kemudian masukkan struktur database dibawah ini.

 

CREATE TABLE `tblvehicles` (
  `id` int(11) NOT NULL,
  `VehiclesTitle` varchar(150) DEFAULT NULL,
  `Vimage1` varchar(120) DEFAULT NULL,
  `Vimage2` varchar(120) DEFAULT NULL,
  `Vimage3` varchar(120) DEFAULT NULL,
  `Vimage4` varchar(120) DEFAULT NULL,
  `Vimage5` varchar(120) DEFAULT NULL,
  `RegDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `UpdationDate` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


INSERT INTO `tblvehicles` (`id`, `VehiclesTitle`, `Vimage1`, `Vimage2`, `Vimage3`, `Vimage4`, `Vimage5`, `RegDate`, `UpdationDate`) VALUES
(11, 'Toyota Avanza', 'about_services_faq_bg.jpg', 'banner-image.jpg', 'car_755x430.png', 'featured-img-1.jpg', 'featured-img-3.jpg', '2018-10-18 17:44:11', NULL),
(12, 'Toyota Rush', 'looking-used-car.png', 'listing_img3.jpg', 'knowledge_base_bg.jpg', 'featured-img-3.jpg', 'featured-img-1.jpg', '2018-10-18 17:44:46', NULL);


ALTER TABLE `tblvehicles`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `tblvehicles`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;
COMMIT;
 

Berikutnya buat file dengan nama config.php file ini berisi script untuk koneksi kedatabase.

 <?php 
// DB credentials.
define('DB_HOST','localhost');
define('DB_USER','root');
define('DB_PASS','');
define('DB_NAME','carrental');
// Establish database connection.
try
{
 $dbh = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME,DB_USER, DB_PASS,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
}
catch (PDOException $e)
{
 exit("Error: " . $e->getMessage());
}
?> 

Kemudian buat file dengan nama index.php form ini berisi script sebagai form upload gambar.



 <?php
session_start();
error_reporting(0);
include('config.php');
if(strlen($_SESSION['alogin'])==0)
{ 
 header('location:index.php');
}
else{ 

 if(isset($_POST['submit']))
 {
  $vehicletitle=$_POST['vehicletitle'];
  $vimage1=$_FILES["img1"]["name"];
  $vimage2=$_FILES["img2"]["name"];
  $vimage3=$_FILES["img3"]["name"];
  $vimage4=$_FILES["img4"]["name"];
  $vimage5=$_FILES["img5"]["name"];

  move_uploaded_file($_FILES["img1"]["tmp_name"],"img/vehicleimages/".$_FILES["img1"]["name"]);
  move_uploaded_file($_FILES["img2"]["tmp_name"],"img/vehicleimages/".$_FILES["img2"]["name"]);
  move_uploaded_file($_FILES["img3"]["tmp_name"],"img/vehicleimages/".$_FILES["img3"]["name"]);
  move_uploaded_file($_FILES["img4"]["tmp_name"],"img/vehicleimages/".$_FILES["img4"]["name"]);
  move_uploaded_file($_FILES["img5"]["tmp_name"],"img/vehicleimages/".$_FILES["img5"]["name"]);

  $sql="INSERT INTO tblvehicles(VehiclesTitle,Vimage1,Vimage2,Vimage3,Vimage4,Vimage5) VALUES(:vehicletitle,:vimage1,:vimage2,:vimage3,:vimage4,:vimage5)";

  $query = $dbh->prepare($sql);
  $query->bindParam(':vehicletitle',$vehicletitle,PDO::PARAM_STR);
  $query->bindParam(':vimage1',$vimage1,PDO::PARAM_STR);
  $query->bindParam(':vimage2',$vimage2,PDO::PARAM_STR);
  $query->bindParam(':vimage3',$vimage3,PDO::PARAM_STR);
  $query->bindParam(':vimage4',$vimage4,PDO::PARAM_STR);
  $query->bindParam(':vimage5',$vimage5,PDO::PARAM_STR);
  $query->execute();
  $lastInsertId = $dbh->lastInsertId();
  if($lastInsertId)
  {
   $msg="Vehicle posted successfully";
  }
  else 
  {
   $error="Something went wrong. Please try again";
  }
 }

 ?>
 <!DOCTYPE html>
 <html>
 <head>
  <title>Add Gambar</title>
  <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
  <script src="bootstrap/js/bootstrap.min.js"></script>
 </head>
 <body>
  <nav class="navbar navbar-default navbar-static-top">
   <div class="container-fluid">
    <div class="navbar-header">
     <a class="navbar-brand" href="https://www.tutorialswb.com/">TutorialsWB</a>
     <ul class="nav navbar-nav">
      <li class="active"><a href="index.php">Home</a></li>
     </ul>
    </div>
   </div>
  </nav>
  <div class="container">
   <div class="page-header">
    <h1 class="h2">Add Vehicle<a class="btn btn-success" href="view-vehicle.php" style="margin-left: 770px;"><span class="glyphicon glyphicon-user"></span>&nbsp; View Vehicles</a></h1><hr>
   </div>
   <?php if($error){?>
    <div class="alert alert-danger">
     <span class="glyphicon glyphicon-info-sign"></span>ERROR : <strong><?php echo htmlentities($error); ?></strong>
    </div>
   <?php } 
   else if($msg){?>
    <div class="alert alert-success">
     <span class="glyphicon glyphicon-info-sign"></span>SUCCESS : <strong><?php echo htmlentities($msg); ?></strong>
     </div><?php }?>
     

     <form method="post" enctype="multipart/form-data">
      
      <div class="form-group">
       <label for="gambar1">Enter Your Title Vehicle</label>
       <input type="text" class="form-control" name="vehicletitle" placeholder="Enter Your Title Vehicle" required="">
      </div>
      <div class="form-group">
       <label for="gambar1">upload your image 1</label>
       <input type="file" class="form-control" name="img1" required="">
      </div> 
      <div class="form-group">
       <label for="gambar1">upload your image 2</label>
       <input type="file" class="form-control" name="img2" required="">
      </div>
      <div class="form-group">
       <label for="gambar1">upload your image 3</label>
       <input type="file" class="form-control" name="img3" required="">
      </div>
      <div class="form-group">
       <label for="gambar1">upload your image 4</label>
       <input type="file" class="form-control" name="img4" required="">
      </div>
      <div class="form-group">
       <label for="gambar1">upload your image 5</label>
       <input type="file" class="form-control" name="img5" required="">
      </div>

      <div class="form-group">
       <button class="btn btn-default" type="reset">Cancel</button>&nbsp;
       <button class="btn btn-primary" name="submit" type="submit" >Save changes</button>

      </div>
     </form>
    </div>
   </body>
   </html>
   <?php } ?> 

Berikutnya buat file dengan nama view-vehicle.php file ini berfungsi untuk menampilkan data gambar dari database.



 <?php
session_start();
error_reporting(0);
include('config.php');
if(strlen($_SESSION['alogin'])==0)
{ 
 header('location:index.php');
}
else{

 if(isset($_REQUEST['del']))
 {
  $delid=intval($_GET['del']);
  $sql = "delete from tblvehicles  WHERE  id=:delid";
  $query = $dbh->prepare($sql);
  $query -> bindParam(':delid',$delid, PDO::PARAM_STR);
  $query -> execute();
  $msg="Vehicle  record deleted successfully";
 }


 ?>
 <!DOCTYPE html>
 <html>
 <head>
  <title>View Gambar</title>
  <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
  <script src="bootstrap/js/bootstrap.min.js"></script>
 </head>
 <body>
  <nav class="navbar navbar-default navbar-static-top">
   <div class="container-fluid">
    <div class="navbar-header">
     <a class="navbar-brand" href="https://www.tutorialswb.com/">TutorialsWB</a>
     <ul class="nav navbar-nav">
      <li class="active"><a href="index.php">Home</a></li>
     </ul>
    </div>
   </div>
  </nav>
  <div class="container">
   <div class="page-header">
    <h1 class="h2">&nbsp; List Users<a class="btn btn-success" href="index.php" style="margin-left: 770px;"><span class="glyphicon glyphicon-user"></span>&nbsp; Back Home</a></h1><hr>
   </div>
   <?php if($error){?>
    <div class="alert alert-danger">
     <span class="glyphicon glyphicon-info-sign"></span>ERROR : <strong><?php echo htmlentities($error); ?></strong>
    </div>
   <?php } 
   else if($msg){?>
    <div class="alert alert-success">
     <span class="glyphicon glyphicon-info-sign"></span>SUCCESS : <strong><?php echo htmlentities($msg); ?></strong>
     </div><?php }?>
     
     <table class="table table-dark">
      <thead>
       <tr>
        <th scope="col">No</th>
        <th scope="col">Vehicless Title</th>
        <th scope="col">Deleted</th>
        <th scope="col">Edit</th>
       </tr>
      </thead>

      
      <?php $sql = "SELECT * from  tblvehicles ";
      $query = $dbh -> prepare($sql);
      $query->execute();
      $results=$query->fetchAll(PDO::FETCH_OBJ);
      $cnt=1;
      if($query->rowCount() > 0)
      {
       foreach($results as $result)
        {    ?>
         
         <tbody>
          <tr>
           <th scope="row"><?php echo htmlentities($cnt);?></th>
           <td><?php echo htmlentities($result->VehiclesTitle);?></td>
           <td><button type="button" class="btn btn-warning"><a href="view-details.php?id=<?php echo $result->id;?>">View Details</a></button></td>
           <td><button type="button" class="btn btn-danger"><a href="view-vehicle.php?del=<?php echo $result->id;?>" onclick="return confirm('Do you want to delete');">Deleted</a></button></td>
          </tr>
          <?php $cnt=$cnt+1; }} ?>
         </tbody>
        </table>
       </div>
      </body>
      </html>
      <?php } ?> 

Yang terakhir kalia harus membuat file dengan view-details.php file ini mempunyai fungsi untuk menampilkan details gambar yang ada di database.



 <?php
session_start();
error_reporting(0);
include('config.php');
if(strlen($_SESSION['alogin'])==0)
{ 
 header('location:index.php');
}


?>
<html>
<head>
 <title>Edit Image</title>
 <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
 <script src="bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
 <nav class="navbar navbar-default navbar-static-top">
  <div class="container-fluid">
   <div class="navbar-header">
    <a class="navbar-brand" href="https://www.tutorialswb.com/">TutorialsWB</a>
    <ul class="nav navbar-nav">
     <li class="active"><a href="index.php">Home</a></li>
    </ul>
   </div>
  </div>
 </nav>
 <div class="container">
  <div class="page-header">
   <h1 class="h2">&nbsp; List Users<a class="btn btn-success" href="view-vehicle.php" style="margin-left: 770px;"><span class="glyphicon glyphicon-user"></span>&nbsp; Back View Vehicle</a></h1><hr>
  </div>
  
  
  <?php if($msg){?>
   <div class="alert alert-success">
    
    <span class="glyphicon glyphicon-info-sign"></span>SUCCESS : <strong><?php echo htmlentities($msg); ?></strong>
    </div><?php }?>
    
    <form method="post" enctype="multipart/form-data">
     <?php
     $id=intval($_GET['id']);

     $sql = "SELECT * from  tblvehicles where tblvehicles.id=:id";
     $query = $dbh -> prepare($sql);
     $query-> bindParam(':id', $id, PDO::PARAM_STR);
     $query->execute();
     $results=$query->fetchAll(PDO::FETCH_OBJ);
     $cnt=1;
     if($query->rowCount() > 0)
     {
      foreach($results as $result)
       { ?>
        
        
        <div class="form-group">
         <label for="vehicletitle">Enter Your New Title Vehicle</label>
         <input type="text" name="vehicletitle" class="form-control" value="<?php echo htmlentities($result->VehiclesTitle)?>" readonly>
        </div>
        
        <div class="form-group">
         <div class="col-sm-4">
          Image 1 <img src="img/vehicleimages/<?php echo htmlentities($result->Vimage1);?>" width="300" height="200" style="border:solid 1px #000">
         </div>
         <div class="col-sm-4">
          Image 2<img src="img/vehicleimages/<?php echo htmlentities($result->Vimage2);?>" width="300" height="200" style="border:solid 1px #000">
         </div>
         <div class="col-sm-4">
          Image 3<img src="img/vehicleimages/<?php echo htmlentities($result->Vimage3);?>" width="300" height="200" style="border:solid 1px #000">
         </div>
        </div>
        


        <div class="form-group">
         <div class="col-sm-4">
          Image 4<img src="img/vehicleimages/<?php echo htmlentities($result->Vimage4);?>" width="300" height="200" style="border:solid 1px #000">
         </div>
         <div class="col-sm-4">
          Image 5
          <?php if($result->Vimage5=="")
          {
           echo htmlentities("File not available");
          } else {?>
           <img src="img/vehicleimages/<?php echo htmlentities($result->Vimage5);?>" width="300" height="200" style="border:solid 1px #000">
          <?php } ?>
         </div>
        </div>
        
       <?php } ?>
       

      </form>
     </div>
    </body>
    </html>
    <?php } ?> 

kalian bisa melihat demo dan bisa langsung mendownload filenya supaya kalian bisa lebih mencoba dan mempelajari sendiri.

DEMO     DOWNLOAD

Sekian share kali ini semoga apa yang kami share kali ini bermanfaat bagi anda jangan lupa share keteman dan jangan segang untuk meninggalkan komentar dibawah dan mulai berdiskusi dengan kami.

//lh4.googleusercontent.com/-eAXyxy2JJKA/AAAAAAAAAAI/AAAAAAAAGS4/OHgzqHzCvtQ/s512-c/photo.jpg

Delete Multiple Menggunakan PHP MySQL dan PDO

Kali ini kami akan share bagaimana membuat delete multiple menggunakan PHP MySQL dan PDO. Sistem ini terlihat simple tetapi mempunyai fungsi yang besar dan sangat berguna.



Ada beberapa yang harus yang harus dipersiapkan, di antaranya adalah membuat struktur database, buat database dengan nama pdo kemudian masukkan struktur database dibawah ini.

 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";

CREATE TABLE `members` (
  `id` int(11) NOT NULL,
  `nama_depan` varchar(100) NOT NULL,
  `alamat` varchar(100) NOT NULL,
  `kelas` varchar(10) NOT NULL,
  `umur` int(5) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `members` (`id`, `nama_depan`, `alamat`, `kelas`, `umur`) VALUES
(1, 'Andi Abidzar', 'Jl. Pelita', 'II', 22),
(2, 'Dede Ahmad', 'Jl. Alauddin', 'III', 22),
(3, 'Irsyad Khalid', 'Palopo, Sulawesi', 'IV', 22),
(4, 'Ahmad Noer', 'J. Perintis Kemerdekaan', 'V', 3);

ALTER TABLE `members`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `members`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
COMMIT; 

Kedua buat file dengan nama dbConfig.php file ini berisi script untuk koneksi kedatabase.

 <?php
$db_host  = 'localhost';
$db_user  = 'root';
$db_pass  = '';
$db_database = 'pdo'; 

$db = new PDO('mysql:host='.$db_host.';dbname='.$db_database, $db_user, $db_pass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
?> 

Ketiga buat file dengan nama index.php file ini sebagai form untuk menampilkan data yang ada didalam database.

 <!DOCTYPE html>
<html>
<head>
  <title>Deleted Multiple</title>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>


  <script type="text/javascript">
    function delete_confirm(){
      var result = confirm("Are you sure to delete users?");
      if(result){
        return true;
      }else{
        return false;
      }
    }
  </script>
</head>
<body>
  <br /><br />
  <div class="container">
   <nav class="navbar navbar-inverse">
    <div class="container-fluid">
     <div class="navbar-header">
      <a class="navbar-brand" href="tutorialswb.com">Deleted Multiple</a>
    </div>
  </div>
</nav>
<br />
<h2 align="center">DELETED MULTIPLE USING PHP PDO</h2>
<br />

<form name="bulk_action_form" action="action.php" method="post" onSubmit="return delete_confirm();"/>
<table class="table">
  <thead>
    <tr>
      <th> &nbsp; </th>
      <th> Nama Lengkap </th>
      <th> Alamat Lengkap </th>
      <th> Umur </th>
      <th> Kelas </th>
    </tr>
  </thead>
  <tbody>
   <?php
   include('dbConfig.php');
   $result = $db->prepare("SELECT * FROM members ORDER BY id DESC");
   $result->execute();
   for($i=0; $row = $result->fetch(); $i++){
     ?>
     <tr class="record">
      <td><input name="selector[]" type="checkbox" value="<?php echo $row['id']; ?>"></td>
      <td><?php echo $row['nama_depan']; ?></td>
      <td><?php echo $row['alamat']; ?></td>
      <td><?php echo $row['umur']; ?></td>
      <td><?php echo $row['kelas']; ?></td>
    </tr>
    <?php
  }
  ?>
</tbody>
</table>
<input type="submit" class="btn btn-danger" name="bulk_delete_submit" value="Delete"/>
</form>
</div>

<!--Script Javascript-->

</body>
</html> 

Keempat buat file dengan nama action.php file ini berisi script atau perintah untuk menghapus data yang ada di database.

 <?php
include('dbConfig.php');

$edittable=$_POST['selector'];
$N = count($edittable);
for($i=0; $i < $N; $i++)
{
 $result = $db->prepare("DELETE FROM members WHERE id= :memid");
 $result->bindParam(':memid', $edittable[$i]);
 $result->execute();
}
header("location: index.php");
mysql_close($con);
?> 

Kalian bisa mendownload file dan melihat langsung file demonya dibawah ini.

DEMO      DOWNLOAD

Sekian share kali ini semoga apa yang kami share bermanfaat bagi anda, jika kalian belum paham atau ingin request post silahkan tinggalkan monetra dibawah dan mulai berdiskusi dengan kami.

//lh4.googleusercontent.com/-eAXyxy2JJKA/AAAAAAAAAAI/AAAAAAAAGS4/OHgzqHzCvtQ/s512-c/photo.jpg

Membuat Contact Form Menggunakan SMTP

Selamat pagi kali ini kami akan share contoh contact form menggunakan PHP, dan pada post terakhir dibawah kalian bisa langsung melihat dan mendownload filenya secara langsung dan silahkan mencoba dan memodifikasi sesuai dengan yang anda perlukan.


Langsung saja yang perlu kalian lakukan adalah membuat formnya terlebih dahulu, buat file dengan nama index.php kemudian masukkan script form dan script validasi contact.

 <!DOCTYPE html>

<html lang="en">

<head>

 <title>Contact Us</title>

 <meta charset="UTF-8">

 <meta name="viewport" content="width=device-width, initial-scale=1">

 <!--===============================================================================================-->

 <link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css">

 <!--===============================================================================================-->

 <link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.7.0/css/font-awesome.min.css">

 <!--===============================================================================================-->

 <link rel="stylesheet" type="text/css" href="fonts/iconic/css/material-design-iconic-font.min.css">

 <!--===============================================================================================-->

 <link rel="stylesheet" type="text/css" href="vendor/animate/animate.css">

 <!--===============================================================================================-->

 <link rel="stylesheet" type="text/css" href="vendor/css-hamburgers/hamburgers.min.css">

 <!--===============================================================================================-->

 <link rel="stylesheet" type="text/css" href="vendor/animsition/css/animsition.min.css">

 <!--===============================================================================================-->

 <link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css">

 <!--===============================================================================================-->

 <link rel="stylesheet" type="text/css" href="vendor/daterangepicker/daterangepicker.css">

 <!--===============================================================================================-->

 <link rel="stylesheet" type="text/css" href="vendor/noui/nouislider.min.css">

 <!--===============================================================================================-->

 <link rel="stylesheet" type="text/css" href="css/util.css">

 <link rel="stylesheet" type="text/css" href="css/main.css">

 <script src="https://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>

 <!--===============================================================================================-->



 <script type="text/javascript">

  $(document).ready(function (e){

   $("#frmContact").on('submit',(function(e){

    e.preventDefault();

    var valid; 

    valid = validateContact();

    if(valid) {

     $.ajax({

      url: "mail.php",

      type: "POST",

      data:  new FormData(this),

      contentType: false,

      cache: false,

      processData:false,

      success: function(data){

       $("#mail-status").html(data);

      },

      error: function(){}          



     });

    } 

   }));



   function validateContact() {

    var valid = true; 

    $(".demoInputBox").css('background-color','');

    $(".info").html('');



    if(!$("#userName").val()) {

     valid = false;

    }

    if(!$("#userEmail").val()) {

     valid = false;

    }

    if(!$("#userEmail").val().match(/^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/)) {

     $("#userEmail-info").html("(invalid)");

     valid = false;

    }

    if(!$("#subject").val()) {

     valid = false;

    }

    if(!$("#content").val()) {

     valid = false;

    }



    return valid;

   }



  });

 </script>

</head>

<body>

 <div class="container-contact100">

  <div class="wrap-contact100">

   <form id="frmContact" action="" method="post" class="contact100-form validate-form">


    <span class="contact100-form-title">

     Contact Us

    </span>

 

    <div class="alert alert-primary" role="alert">

     <div id="mail-status"></div>

    </div>

    

    <div class="wrap-input100 validate-input bg1" data-validate="Please Type Your Name">

     <span class="label-input100">FULL NAME *</span>

     <input class="input100" type="text" name="userName" id="userName" placeholder="Enter Your Name" required="">

    </div>



    <div class="wrap-input100 validate-input bg1 rs1-wrap-input100" data-validate = "Enter Your Email (e@a.x)">

     <span class="label-input100">Email *</span>

     <input class="input100" type="text" name="userEmail" id="userEmail" placeholder="Enter Your Email" required="">

    </div>



    <div class="wrap-input100 bg1 rs1-wrap-input100">

     <span class="label-input100">Phone</span>

     <input class="input100" type="text" name="subject" id="subject" placeholder="Enter Number Phone" required="">

    </div>



    <div class="wrap-input100 validate-input bg0 rs1-alert-validate" data-validate = "Please Type Your Message">

     <span class="label-input100">Message</span>

     <textarea class="input100" name="content" id="content" placeholder="Your message here..." required=""></textarea>

    </div>



    <div class="container-contact100-form-btn">

     <button class="contact100-form-btn" type="submit">

      <span>

       Submit

       <i class="fa fa-long-arrow-right m-l-7" aria-hidden="true"></i>

      </span>

     </button>

    </div>

   </form>

  </div>

 </div>

 <!--===============================================================================================-->

 <script src="vendor/jquery/jquery-3.2.1.min.js"></script>

 <!--===============================================================================================-->

 <script src="vendor/animsition/js/animsition.min.js"></script>

 <!--===============================================================================================-->

 <script src="vendor/bootstrap/js/popper.js"></script>

 <script src="vendor/bootstrap/js/bootstrap.min.js"></script>

 <!--===============================================================================================-->

 <script src="vendor/select2/select2.min.js"></script>

 <!--===============================================================================================-->

 <script src="vendor/daterangepicker/moment.min.js"></script>

 <script src="vendor/daterangepicker/daterangepicker.js"></script>

 <!--===============================================================================================-->

 <script src="vendor/countdowntime/countdowntime.js"></script>

 <!--===============================================================================================-->

 <script src="vendor/noui/nouislider.min.js"></script>

 <!--===============================================================================================-->

 <script src="js/main.js"></script>

</body>

</html>

 
Kemudian buat file dengan nama mail.php disini kami menggunakan jQuery Ajax, fungsinya adalah untuk memanggil skrip email PHP untuk mengirim email kontak menggunakan SMTP Gmail.

 <?php
require('phpmailer/class.phpmailer.php');

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = TRUE;
$mail->SMTPSecure = "tls";
$mail->Port     = 587;  
$mail->Username = "SMTP Username";
$mail->Password = "SMTP Password";
$mail->Host     = "SMTP Host";
$mail->Mailer   = "smtp";
$mail->SetFrom($_POST["userEmail"], $_POST["userName"]);
$mail->AddReplyTo($_POST["userEmail"], $_POST["userName"]);
$mail->AddAddress("Email Penerima"); 
$mail->Subject = $_POST["subject"];
$mail->WordWrap   = 80;
$mail->MsgHTML($_POST["content"]);


$mail->IsHTML(true);

if(!$mail->Send()) {
 echo "<p class='error'>Problem in Sending Mail.</p>";
} else {
 echo "<p class='success'>Contact Mail Sent.</p>";
} 
?> 

Kalian ubah username, password dan host sesuai yang anda punya pada hosting anda, Kemudian anda juga harus memasukkan email penerima. Kalian bisa melihat dan langsung mendownload filenya dibawah ini.

DEMO     DOWNLOAD

Sekian share kali ini jika kalian belum paham dengan penggunaan SMTP di atas bisa meninggalkan komentar dibawah dan mulai berdiskusi dengan kami.

//lh3.googleusercontent.com/-K5UKWzgJhmU/AAAAAAAAAAI/AAAAAAAACdI/CN3nwiBZsGE/s512-c/photo.jpg

Membuat Shopping Cart Simple Menggunakan PHP

Selamat pagi sobat blogger kali ini kami akan share bagaimana membuat shopping cart simple menggunakan PHP, disamping itu kami menggunakan bootsrap sebagai kerangka tampilan pada app shopping cart.



Langsung saa yang pertama kita diharuskan membuat database, buat database dengan nama shopping kemudian masukkan struktur database dibawah ini.

 
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";


CREATE TABLE `products` (
  `id` int(11) NOT NULL,
  `name` varchar(200) NOT NULL,
  `price` double NOT NULL,
  `photo` varchar(150) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


INSERT INTO `products` (`id`, `name`, `price`, `photo`) VALUES
(1, 'DELL Inspiron 15 7000 15.6', 899, 'images/1.jpg'),
(2, 'MICROSOFT Surface Pro 4 & Typecover - 128 GB', 799, 'images/2.jpg'),
(3, 'DELL Inspiron 15 5000 15.6', 599, 'images/3.jpg'),
(4, 'LENOVO Ideapad 320s-14IKB 14\" Laptop - Grey', 399, 'images/4.jpg');


ALTER TABLE `products`
  ADD PRIMARY KEY (`id`);


ALTER TABLE `products`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
COMMIT;
 

Buat file dengan nama index.php, file ini akan berfungsi untuk menampilkan produk dan pada file ini terdapat form_modal untuk menambahkan produk.


 <?php
session_start();
 //initialize cart if not set or is unset
if(!isset($_SESSION['cart'])){
 $_SESSION['cart'] = array();
}

 //unset qunatity
unset($_SESSION['qty_array']);
?>
<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8">
 <title>Hopping Cart</title>
 <link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css">
 <style>
 .product_image{
  height:200px;
 }
 .product_name{
  height:80px; 
  padding-left:20px; 
  padding-right:20px;
 }
 .product_footer{
  padding-left:20px; 
  padding-right:20px;
 }
</style>
</head>
<body>
 <br/>
 <div class="container">
  <nav class="navbar navbar-default">
   <div class="container-fluid">
    <div class="navbar-header">
     <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
      <span class="sr-only">Toggle navigation</span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
     </button>
     <a class="navbar-brand" href="#">Shopping Cart</a>
    </div>

    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
     <ul class="nav navbar-nav">
      <!-- left nav here -->
     </ul>
     <ul class="nav navbar-nav navbar-right">
      <li><a href="view_cart.php"><span class="badge"><?php echo count($_SESSION['cart']); ?></span> Cart <span class="glyphicon glyphicon-shopping-cart"></span></a></li>
     </ul>
    </div>
   </div>
  </nav>
  <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#form_modal"><span class="glyphicon glyphicon-plus"></span> Add Product</button>
  <p/>
  <?php
  //info message
  if(isset($_SESSION['message'])){
   ?>
   <div class="row">
    <div class="col-sm-6 col-sm-offset-6">
     <div class="alert alert-info text-center">
      <?php echo $_SESSION['message']; ?>
     </div>
    </div>
   </div>
   <?php
   unset($_SESSION['message']);
  }


  //connection
  $conn = new mysqli('localhost', 'root', '', 'shopping');

  $sql = "SELECT * FROM products";
  $query = $conn->query($sql);
  $inc = 4;
  while($row = $query->fetch_assoc()){
   $inc = ($inc == 4) ? 1 : $inc + 1; 
   if($inc == 1) echo "<div class='row text-center'>";  
   ?>
   <div class="col-sm-3">
    <div class="panel panel-default">
     <div class="panel-body">
      <div class="row product_image">
       <img src="<?php echo $row['photo'] ?>" width="80%" height="auto">
      </div>
      <div class="row product_name">
       <h4><?php echo $row['name']; ?></h4>
      </div>
      <div class="row product_footer">
       <p class="pull-left"><b><?php echo $row['price']; ?></b></p>
       <span class="pull-right"><a href="add_cart.php?id=<?php echo $row['id']; ?>" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-plus"></span> Cart</a></span>
      </div>
     </div>
    </div>
   </div>
   <?php
  }
  if($inc == 1) echo "<div></div><div></div><div></div></div>"; 
  if($inc == 2) echo "<div></div><div></div></div>"; 
  if($inc == 3) echo "<div></div></div>";
  
  //end product row 
  ?>

 </div>

   <div class="modal fade" id="form_modal" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog" role="document">
   <form action="save_query.php" method="POST" enctype="multipart/form-data">
    <div class="modal-content">
     <div class="modal-body">
      <div class="col-md-2"></div>
      <div class="col-md-8">
       <div class="form-group">
        <label>Product Name</label>
        <input class="form-control" type="text" name="name">
       </div>
       <div class="form-group">
        <label>Product Price</label>
        <input class="form-control" type="number" name="price">
       </div>
       <div class="form-group">
        <label>Product Photo</label>
        <input class="form-control" type="file" name="photo">
       </div>
      </div>
     </div>
     <div style="clear:both;"></div>
     <div class="modal-footer">
      <button type="button" class="btn btn-danger" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Close</button>
      <button name="save" class="btn btn-primary"><span class="glyphicon glyphicon-save"></span> Save</button>
     </div>
    </div>
   </form>
  </div>
 </div>
</body>
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/bootstrap.js"></script>
</html> 

Berikutnya buat file dengan nama add_cart.php file ini berisi script berfungsi sebagai add to chart.

 <?php
 session_start();

 //periksa apakah produk sudah ada dalam keranjang
 if(!in_array($_GET['id'], $_SESSION['cart'])){
  array_push($_SESSION['cart'], $_GET['id']);
  $_SESSION['message'] = 'Product added to cart';
 }
 else{
  $_SESSION['message'] = 'Product already in cart';
 }

 header('location: index.php');
?> 



Gambat diatas merupakan tampilan view cart, Berikutnya buat file dengan nama view_cart.php file ini berfungsi ini berisi cript yang berfungsi untuk menampilkan produk yang ada pada keranjangnya.

 <?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8">
 <title>Shopping Cart</title>
 <link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css">
</head>
<body>
 <br/>
 <div class="container">
  <nav class="navbar navbar-default">
   <div class="container-fluid">
    <div class="navbar-header">
     <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
      <span class="sr-only">Toggle navigation</span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
     </button>
     <a class="navbar-brand" href="#">Shopping Cart</a>
    </div>

    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
     <ul class="nav navbar-nav">
      <!-- left nav here -->
     </ul>
     <ul class="nav navbar-nav navbar-right">
      <li class="active"><a href="view_cart.php"><span class="badge"><?php echo count($_SESSION['cart']); ?></span> Cart <span class="glyphicon glyphicon-shopping-cart"></span></a></li>
     </ul>
    </div>
   </div>
  </nav>
  <div class="row">
   <div class="col-sm-8 col-sm-offset-2">
    <?php 
    if(isset($_SESSION['message'])){
     ?>
     <div class="alert alert-info text-center">
      <?php echo $_SESSION['message']; ?>
     </div>
     <?php
     unset($_SESSION['message']);
    }

    ?>
    <form method="POST" action="save_cart.php">
     <table class="table table-bordered table-striped">
      <thead>
       <th></th>
       <th>Name</th>
       <th>Price</th>
       <th>Quantity</th>
       <th>Subtotal</th>
      </thead>
      <tbody>
       <?php
      //initialize total
       $total = 0;
       if(!empty($_SESSION['cart'])){
      //connection
        $conn = new mysqli('localhost', 'root', '', 'shopping');
      //create array of initail qty which is 1
        $index = 0;
        if(!isset($_SESSION['qty_array'])){
         $_SESSION['qty_array'] = array_fill(0, count($_SESSION['cart']), 1);
        }
        $sql = "SELECT * FROM products WHERE id IN (".implode(',',$_SESSION['cart']).")";
        $query = $conn->query($sql);
        while($row = $query->fetch_assoc()){
         ?>
         <tr>
          <td>
           <a href="delete_item.php?id=<?php echo $row['id']; ?>&index=<?php echo $index; ?>" class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-trash"></span></a>
          </td>
          <td><?php echo $row['name']; ?></td>
          <td><?php echo number_format($row['price'], 2); ?></td>
          <input type="hidden" name="indexes[]" value="<?php echo $index; ?>">
          <td><input type="text" class="form-control" value="<?php echo $_SESSION['qty_array'][$index]; ?>" name="qty_<?php echo $index; ?>"></td>
          <td><?php echo number_format($_SESSION['qty_array'][$index]*$row['price'], 2); ?></td>
          <?php $total += $_SESSION['qty_array'][$index]*$row['price']; ?>
         </tr>
         <?php
         $index ++;
        }
       }
       else{
        ?>
        <tr>
         <td colspan="4" class="text-center">No Item in Cart</td>
        </tr>
        <?php
       }

       ?>
       <tr>
        <td colspan="4" align="right"><b>Total</b></td>
        <td><b><?php echo number_format($total, 2); ?></b></td>
       </tr>
      </tbody>
     </table>
     <a href="index.php" class="btn btn-primary"><span class="glyphicon glyphicon-arrow-left"></span> Back</a>
     <button type="submit" class="btn btn-success" name="save">Save Changes</button>
     <a href="clear_cart.php" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span> Clear Cart</a>
     <a href="checkout.php" class="btn btn-success"><span class="glyphicon glyphicon-check"></span> Checkout</a>
    </form>
   </div>
  </div>
 </div>
</body>
</html> 

Buat file dengan nama save_query.php, file ini berisi script untuk menambahkan produk kedalam database.

 <?php
 $conn = new mysqli('localhost', 'root', '', 'shopping');
 
 if(ISSET($_POST['save'])){
  if(!empty($_POST['name']) && !empty($_POST['price'])){
   $name = addslashes($_POST['name']);
   $price = $_POST['price'];
 
   $file = explode(".", $_FILES['photo']['name']);
   $ext = array("png", "gif", "jpg", "jpeg");
 
   if(in_array($file[1], $ext)){
    $file_name = $file[0].'.'.$file[1];
    $tmp_file = $_FILES['photo']['tmp_name'];
    $location = "images/".$file_name;
    $new_location = addslashes($location);
 
    if(move_uploaded_file($tmp_file, $location)){
     $conn->query("INSERT INTO `products` VALUES('', '$name', '$price', '$new_location')");
     echo "<script>alert('Data Insert')</script>";
     echo "<script>window.location = 'index.php'</script>";
    }
 
   }else{
    echo "<script>alert('File not available')</script>";
    echo "<script>window.location = 'index.php'</script>";
   }
 
  }else{
   echo "<script>alert('Please complete the required field!')</script>";
  }
 
 
 }
?> 

Berikutnya buat file dengan nama delete_item.php file ini berfungsi untuk menghapus item dari keranjang yang sudah ditambahkan.

 <?php
 session_start();

 //hapus id dari larik keranjang kami
 $key = array_search($_GET['id'], $_SESSION['cart']); 
 unset($_SESSION['cart'][$key]);

 unset($_SESSION['qty_array'][$_GET['index']]);
 //mengatur ulang array setelah tidak disetel
 $_SESSION['qty_array'] = array_values($_SESSION['qty_array']);

 $_SESSION['message'] = "Product deleted from cart";
 header('location: view_cart.php');
?> 

Berikutnya buat file dengan nama save_cart.php file ini berisi script yang berfungsi untuk menyimpan produk yang ditambahkan atau produk yang telah di edit pada produk keranjang.

 <?php
 session_start();
 if(isset($_POST['save'])){
  foreach($_POST['indexes'] as $key){
   $_SESSION['qty_array'][$key] = $_POST['qty_'.$key];
  }

  $_SESSION['message'] = 'Cart updated successfully';
  header('location: view_cart.php');
 }
?>
 

Berikutnya buat file dengan nama clear_cart.php file ini berisi script yang berfungsi untuk membersihkan semua isi keranjang.

 <?php
 session_start();
 unset($_SESSION['cart']);
 $_SESSION['message'] = 'Cart cleared successfully';
 header('location: index.php');
?> 

Berikutnya buat file dengan nama checkout.php. Dalam fungsi umum checkout ini akan mengarahkan user atau pelanggan ke halaman login untuk mengisi identitas secara details. Tetapi dalam fungsi ini checkout ini akan menampilkan pesan bahwa belanjaan yang ada di keranjangnya.

 <?php
 session_start();
 //pengguna perlu login untuk checkout
 $_SESSION['message'] = 'You need to login to checkout';
 header('location: view_cart.php');
?> 

Kalian bisa langsung melihat demo dan bisa langsung dan mendownload filenya untuk bisa langsung mencoba dan mempelajarinya langsung.

DEMO       DOWNLOAD

Sekian share kali ini semoga apa yang kami share bermanfaat bagi anda, Jika kalian belum paham bisa meningggalkan komentar dibawah dan mulai berdiskusi dengan kami.

//lh4.googleusercontent.com/-eAXyxy2JJKA/AAAAAAAAAAI/AAAAAAAAGS4/OHgzqHzCvtQ/s512-c/photo.jpg

Menampilkan Data berdasarkan Bulan Menggunakan PHP

Selamat malam sobat blogger kali ini kami akan share bagaimana menampilkan data yang ada di database berdasarkan bulan yang dipilih. Aplikasi sederhana seperti ini sangat cocok bagi sebuah sistem yang mempunyai data yang sangat banyak.


Langsung saja mari kutai mulai dari tahap demi tahap, ada beberapa yang mesti kalian buat dan setiap file memilik script dan fungsi yang berbeda. Pada setiap file kami akan jelaskan secara detail.

config.php
index.php
filter.php
save.php

Tetapi sebelum itu buat databse terlebih dahulu, buat database dengan nama search.php kemudian masukkan struktur database dibawah ini.

 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";


CREATE TABLE `product` (
  `product_id` int(11) NOT NULL,
  `product_name` varchar(50) NOT NULL,
  `supplier` varchar(50) NOT NULL,
  `date` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


INSERT INTO `product` (`product_id`, `product_name`, `supplier`, `date`) VALUES
(1, 'Iphone X (2018)', 'Iphone', '2018-09-15'),
(2, 'Iphone 8 Plus (2018)', 'Iphone', '2018-08-15'),
(3, 'Iphone 8 (2018)', 'Iphone', '2018-07-15'),
(4, 'Iphone 7 Plus (2018)', 'Iphone', '2018-06-15'),
(5, 'Iphone 7 (2018)', 'Iphone', '2018-05-15'),
(6, 'Iphone 6 Plus (2018)', 'Iphone', '2018-04-15'),
(7, 'Iphone 6 (2018)', 'Iphone', '2018-03-15'),
(8, 'Iphone 5 Plus (2018)', 'Iphone', '2018-02-15'),
(9, 'Iphone 5 (2018)', 'Iphone', '2018-01-15'),
(10, 'Iphone 4 (2018)', 'Iphone', '2018-10-05');


ALTER TABLE `product`
  ADD PRIMARY KEY (`product_id`);

ALTER TABLE `product`
  MODIFY `product_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
COMMIT; 

config.php
File ini berfungsi sebagai koneksi kedatabase.

 <?php
$conn = mysqli_connect('localhost', 'root', '', 'search');

if(!$conn){
 die("Error: Failed to connect to database!");
}
?> 

index.php
File ini berisi script untuk menampilkan data database, berisi script filter dan terdapat form data-model sebagai input data.

 <!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1"/>
 <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/>
</head>
<body>
 <nav class="navbar navbar-default">
  <div class="ocntainer-fluid">
   <a class="navbar-brand" href="https://www.tutorialswb.com/">TutorialsWB.com</a>
  </div>
 </nav>
 <div class="col-md-3"></div>
 <div class="col-md-6 well">
  <button type="button" class="btn btn-success" data-toggle="modal" data-target="#form_modal"><span class="glyphicon glyphicon-plus"></span> Add Product</button>
  <a class="btn btn-info" href="index.php">Display All</a> 
  <br />
  <br />
  <form method="POST" class="form-inline" action="">
   <select name="date" class="form-control" required="required">
    <option value="">Select Month</option>
    <option value="1">January</option>
    <option value="2">February</option>
    <option value="3">March</option>
    <option value="4">April</option>
    <option value="5">May</option>
    <option value="6">June</option>
    <option value="7">July</option>
    <option value="8">August</option>
    <option value="9">September</option>
    <option value="10">October</option>
    <option value="11">November</option>
    <option value="12">December</option>
   </select>
   <button class="btn btn-primary" name="filter"><span class="glyphicon glyphicon-search"></span> Search</button>
  </form>
  <br style="clear:both;"/><br />
  <table class="table table-bordered">
   <thead class="alert-info">
    <tr>
     <th>Product Name</th>
     <th>Supplier Name</th>
     <th>Date</th>
    </tr>
   </thead>
   <tbody>
    <?php include 'filter.php'?>
   </tbody>
  </table>
 </div>
 <div class="modal fade" id="form_modal" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog">
   <form action="save.php" method="POST">
    <div class="modal-content">
     <div class="modal-body">
      <div class="col-md-2"></div>
      <div class="col-md-8">
       <div class="form-group">
        <label>Product Name</label>
        <input type="text" class="form-control" name="product_name" required="required"/>
       </div>
       <div class="form-group">
        <label>Supplier Name</label>
        <input type="text" class="form-control" name="supplier_name" required="required"/>
       </div>
       <div class="form-group">
        <label>Date</label>
        <input type="date" class="form-control" name="date" required="required"/>
       </div>
      </div>
     </div>
     <div style="clear:both;"></div>
     <div class="modal-footer">
      <button type="button" class="btn btn-danger" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Close</button>
      <button name="save" class="btn btn-primary"><span class="glyphicon glyphicon-save"></span> Save</button>
     </div>
    </div>
   </form>
  </div>
 </div>
 <script src="js/jquery-3.2.1.min.js"></script>
 <script src="js/bootstrap.js"></script>
</body>
</html> 

filter.php
Script ii berfungsi fungsi inti dari aplikasi sederhana di atas, dimana script ini akan memfilter data bulan sesuai yang kita pilih meudian menampilkannya kedalam tabel.

 <?php
date_default_timezone_set('Asia/Jakarta');
if(!ISSET($_POST['filter'])){
 ?>
 <?php
 require 'config.php';
 $query = mysqli_query($conn, "SELECT * FROM `product` ORDER BY `date` ASC") or die(mysqli_error());
 while($fetch = mysqli_fetch_array($query)){
  ?>
  <tr>
   <td><?php echo $fetch['product_name']?></td>
   <td><?php echo $fetch['supplier']?></td>
   <td><?php echo date('M d, Y', strtotime($fetch['date']))?></td>
  </tr>
  <?php
 }
 ?>
 
 <?php
}
?>


<?php
if(ISSET($_POST['filter'])){
 require 'config.php';
 $date = $_POST['date'];
 $query = mysqli_query($conn, "SELECT * FROM `product` WHERE MONTH(date) = '$date' ORDER BY `date` ASC") or die(mysqli_error());
 while($fetch = mysqli_fetch_array($query)){
  ?>
  <tr>
   <td><?php echo $fetch['product_name']?></td>
   <td><?php echo $fetch['supplier']?></td>
   <td><?php echo date('M d, Y', strtotime($fetch['date']))?></td>
  </tr> 
  <?php  
 }
}
?> 

save.php
Script ini mempunyai fungsi menginput data kedalam database melalui form data-model yang terdapat pada file index.php

 <?php
 require_once 'config.php';
 
 if(ISSET($_POST['save'])){
  $product_name = $_POST['product_name'];
  $supplier_name = $_POST['supplier_name'];
  $date = $_POST['date'];
  
  mysqli_query($conn, "INSERT INTO `product` VALUES('', '$product_name', '$supplier_name', '$date')") or die(mysqli_error());
  
  header('location: index.php');
 }
 
?> 

Kalian bisa langsung melihat demo aplikasi sederhana di atas, Kalian juga bisa langsung medownload file dibawah ini.

DEMO        DOWNLOAD

Sekian share kali ini semoga apa yang kami share bermanfaat bagi anda, jika kalian belum paham atau kalian ingin request post dan project silahkan tinggalkan komentar dibawah.

//lh3.googleusercontent.com/-K5UKWzgJhmU/AAAAAAAAAAI/AAAAAAAACdI/CN3nwiBZsGE/s512-c/photo.jpg

SUBSCRIBE TO OUR NEWSLETTER