Advertisement
henka04

solve bind_param

Feb 21st, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <?php
  2. include('connect.php');
  3. ?>
  4.  
  5. <fieldset>
  6. <legend>Masukan Data</legend>
  7. <form action="tambah.php" method="post" enctype="multipart/form-data">
  8. Nama Sepeda :<input type="text" name="nama_sepeda">
  9. Size Sepeda :<input type="text" name="size_sepeda">
  10. Harga Sepeda:<input type="text" name="harga_sepeda">
  11. <input type="file" name="gambar">
  12. <input type="submit" name="tambah" value="Tambahkan">
  13. </form>
  14. </fieldset>
  15. <?php
  16. if(isset($_POST['tambah'])){
  17.  
  18. $tempatgambar = $_FILES['gambar']['tmp_name'];
  19. $namagambar = $_FILES['gambar']['name'];
  20. move_uploaded_file($tempatgambar,"gambar/".$namagambar);
  21.  
  22. $query = $db->prepare("INSERT INTO sepeda (nama_sepeda,size_sepeda,harga_sepeda,gambar) VALUES (?,?,?,?)");
  23. $query->bind_param('ssis',$nama,$size,$harga,$gambar);
  24.  
  25. $nama = $_POST['nama_sepeda'];
  26. $size = $_POST['size_sepeda'];
  27. $harga = $_POST['harga_sepeda'];
  28. $gambar = $_FILES['gambar']['name'];
  29. $query->execute();
  30.  
  31. if($query){
  32. echo "data tersimpan";
  33. }else{
  34. echo "data gagal tersimpan";
  35. }
  36.  
  37. $query->close();
  38. $db->close();
  39. }
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement