Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('connect.php');
- ?>
- <fieldset>
- <legend>Masukan Data</legend>
- <form action="tambah.php" method="post" enctype="multipart/form-data">
- Nama Sepeda :<input type="text" name="nama_sepeda">
- Size Sepeda :<input type="text" name="size_sepeda">
- Harga Sepeda:<input type="text" name="harga_sepeda">
- <input type="file" name="gambar">
- <input type="submit" name="tambah" value="Tambahkan">
- </form>
- </fieldset>
- <?php
- if(isset($_POST['tambah'])){
- $tempatgambar = $_FILES['gambar']['tmp_name'];
- $namagambar = $_FILES['gambar']['name'];
- move_uploaded_file($tempatgambar,"gambar/".$namagambar);
- $query = $db->prepare("INSERT INTO sepeda (nama_sepeda,size_sepeda,harga_sepeda,gambar) VALUES (?,?,?,?)");
- $query->bind_param('ssis',$nama,$size,$harga,$gambar);
- $nama = $_POST['nama_sepeda'];
- $size = $_POST['size_sepeda'];
- $harga = $_POST['harga_sepeda'];
- $gambar = $_FILES['gambar']['name'];
- $query->execute();
- if($query){
- echo "data tersimpan";
- }else{
- echo "data gagal tersimpan";
- }
- $query->close();
- $db->close();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement