Postingan lainnya
Kelas Premium!
Belajar bikin website dari nol sekarang
Gunakan kupon "lebihcepat" untuk diskon 25%!
database tidak muncul
halo teman teman sekolah koding, saya ada problem input database, ketika saya sudah inputkan datanya tetapi data tersebut tidak masuk ke database, data yang masuk hanya "kolom auto increment" yang lain kosong? saya sudah koreksi semua dari mulai koneksi, form inputan dan proses input database nya pun sudah saya cek tetapi tetap saja tidak masuk ke database. ada yang bisa bantu?
ini scriptnya :
<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-53014221-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-53014221-1');
</script>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- ===============================================-->
<!-- Document Title-->
<!-- ===============================================-->
<title>Connect with Us | Cosmetic Ingredient Solution</title>
<meta name="description" content="Distributor bahan baku kosmetik & produk konsep advisor terbaik di Indonesia. Active ingredients untuk personal care ter-update untuk produk anti aging, anti-acne, moisturizer, whitening, hair care, dan lain sebagainya.">
<meta name="author" content="PT Tetap Naik Bukan Turun">
<meta name="keywords" content="Bahan baku kosmetik">
<!-- Header -->
<?php include ('header.php');?>
<!-- End Header -->
<br>
<br>
<br>
<br>
<!-- ============================================-->
<!-- <section> begin ============================-->
<section id="booking">
<div class="container">
<div class="row align-items-center">
<div class="col-lg-6">
<div class="mb-4 text-start">
<h5 class="text-secondary wow fadeInRight" data-wow-duration="1s" data-wow-delay="300ms">Easy and Fast in Multi Channel </h5>
<h3 class="fs-xl-10 fs-lg-8 fs-7 fw-bold font-cursive text-capitalize wow fadeInLeft" data-wow-duration="1s" data-wow-delay="300ms">Connect with Us 24/7 in 3 ways</h3>
</div>
<div class="d-flex align-items-start mb-2 wow fadeInRight" data-wow-duration="1s" data-wow-delay="300ms">
<div class="bg-primary me-sm-4 me-3 p-1" style="border-radius: 13px"><a href="https://api.whatsapp.com/send?phone=6281585888185" target="blank"> <img src="assets/img/steps/whatsapp.png" width="50" alt="whatsapp" /></a></div>
<div class="flex-1">
<h5 class="text-secondary fw-bold fs-0">Whatsapp</h5>
<p>Click this number <a href="https://api.whatsapp.com/send?phone=6281585888185" target="blank"> +62815-8588-8185</a> and you will <br class="d-none d-sm-block"> be directly to connect with us via whatsapp 24/7.</p>
</div>
</div>
<div class="d-flex align-items-start mb-2 wow fadeInLeft" data-wow-duration="1s" data-wow-delay="300ms">
<div class="bg-danger me-sm-4 me-3 p-1" style="border-radius: 13px"> <a href="mailto:info@my-solution.co.id" target="blank"> <img src="assets/img/steps/email.png" width="50" alt="email" /></a></div>
<div class="flex-1">
<h5 class="text-secondary fw-bold fs-0">Email</h5>
<p>Easy for email Us to get information or discussion 24/7.<br class="d-none d-sm-block">Just one click this address <a href="mailto:info@my-solution.co.id" target="blank">info@my-solution.co.id</a></p>
</div>
</div>
<div class="d-flex align-items-start mb-2 wow fadeInRight" data-wow-duration="1s" data-wow-delay="300ms">
<div class="bg-info me-sm-4 me-3 p-1" style="border-radius: 13px"> <a href="https://www.google.com/maps/place/PT+Tetap+Naik+Bukan+Turun/@-6.2084911,106.7635149,15z/data=!4m5!3m4!1s0x0:0xf2530b6466b3291!8m2!3d-6.2085397!4d106.7635199" target="blank"> <img src="assets/img/steps/map.png" width="50" alt="maps" /></a></div>
<div class="flex-1">
<h5 class="text-secondary fw-bold fs-0">Face to Face Meeting</h5>
<p>Lastly, you can directly meeting with us in <br class="d-none d-sm-block"> <a href="https://www.google.com/maps/place/PT+Tetap+Naik+Bukan+Turun/@-6.2084911,106.7635149,15z/data=!4m5!3m4!1s0x0:0xf2530b6466b3291!8m2!3d-6.2085397!4d106.7635199" target="blank">Permata Regency D/37, DKI Jakarta, Indonesia</a><br class="d-none d-sm-block"> by making an appointment 1 days before .</p>
</div>
</div>
</div>
<div class="col-lg-6 d-flex justify-content-center align-items-start wow fadeInDown" data-wow-duration="1s" data-wow-delay="300ms">
<div class="card position-relative shadow" style="max-width: 370px;">
<div class="position-absolute z-index--1 me-10 me-xxl-0" style="right:-160px;top:-210px;"> <img src="assets/img/steps/bg.png" style="max-width:550px;" alt="shape" /></div>
<div class="card-body p-3"> <img class="mb-4 mt-2 rounded-2 w-100" src="assets/img/steps/contact.jpg" alt="contact" />
<div>
<h5 class="fw-medium">Connect with Us</h5>
<p class="fs--1 mb-3 fw-medium">Follow us :</p>
<div class="icon-group mb-4"> <a class="text-decoration-none icon-item shadow-social" id="instagram" href="https://api.whatsapp.com/send?phone=6281585888185"><i class="fab fa-whatsapp"> </i></a><a class="text-decoration-none icon-item shadow-social" id="instagram" href="https://instagram.com/tetapnaik?utm_medium=copy_link"><i class="fab fa-instagram"> </i></a><a class="text-decoration-none icon-item shadow-social" id="instagram" href="#!"><i class="fab fa-twitter"> </i></a><a class="text-decoration-none icon-item shadow-social" id="instagram" href="mailto:info@my-solution.co.id"><i class="fa fa-envelope"> </i></a><a class="text-decoration-none icon-item shadow-social" id="instagram" href="https://www.google.com/maps/place/PT+Tetap+Naik+Bukan+Turun/@-6.2084911,106.7635149,15z/data=!4m5!3m4!1s0x0:0xf2530b6466b3291!8m2!3d-6.2085397!4d106.7635199"><i class="fa fa-map"> </i></a>
</div>
</div>
</div>
</div>
</div>
</div>
</div><!-- end of .container-->
</section>
<!-- <section> close ============================-->
<!-- ============================================-->
<!-- ============================================-->
<!-- <section> begin ============================-->
<section class="pt-6">
<div class="container">
<div class="py-8 px-5 position-relative text-center" style="background-color: rgba(250, 192, 0, 0.199);border-radius: 129px 20px 20px 20px;">
<div class="position-absolute start-100 top-0 translate-middle ms-md-n3 ms-n4 mt-3"> <img src="assets/img/cta/send.png" style="max-width:70px;" alt="send icon" /></div>
<div class="position-absolute end-0 top-0 z-index--1"> <img src="assets/img/cta/shape-bg2.png" width="264" alt="cta shape" /></div>
<div class="position-absolute start-0 bottom-0 ms-3 z-index--1 d-none d-sm-block"> <img src="assets/img/cta/shape-bg1.png" style="max-width: 340px;" alt="cta shape" /></div>
<div class="row justify-content-center">
<div class="col-lg-8 col-md-10">
<h2 class="text-secondary lh-1-7 mb-7">Leave Message Here</h2>
<form class="row g-3 align-items-center w-lg-75 mx-auto" method="post" action="simpan-contact.php">
<div class="input-group-icon">
<input type="text" name="name" placeholder="Enter your name " class="form-control form-little-squirrel-control" /><img class="input-box-icon" src="assets/img/cta/account.png" width="17" alt="mail" />
</div>
<div class="input-group-icon">
<input type="text" name="company" placeholder="Enter company " class="form-control form-little-squirrel-control" /><img class="input-box-icon" src="assets/img/cta/building.png" width="17" alt="mail" />
</div>
<div class="input-group-icon">
<input type="email" name="email" placeholder="Enter email " class="form-control form-little-squirrel-control" /><img class="input-box-icon" src="assets/img/cta/email.png" width="17" alt="mail" />
</div>
<div class="input-group-icon">
<input type="text" name="message" placeholder="Enter message " class="form-control form-little-squirrel-control" /><img class="input-box-icon" src="assets/img/cta/message.png" width="17" alt="mail" />
</div>
<div class="col-sm-auto">
<button class="btn btn-danger orange-gradient-btn fs--1" type="submit">Connect</button>
</div>
</form>
</div>
</div>
</div>
</div><!-- end of .container-->
</section>
<!-- <section> close ============================-->
<!-- ============================================-->
<!-- Footer -->
<?php include ('footer.php');?>
<!-- End Footer -->
</body>
</html>
ini scrip koneksinya :
<?php
$host="localhost";
$user="root";
$password="";
$db="siswa";
$kon = mysqli_connect($host,$user,$password);
if ($kon){
//echo "Database MYSQL <b>berhasil</b> dikoneksikan<br>";
}else {
echo"Database MYSQL <b>gagal</b> dikoneksikan<br>";
}
$hasil=mysqli_select_db($kon,$db);
if ($hasil){
//echo "Database $db berhasil dipilih";
}else {
echo "Database $db gagal dipilih";
}
?>
ini scrip proses simpan ke database :
<?php
//Include file koneksi ke database
include "koneksi.php";
//menerima nilai dari kiriman form input-barang
$name=$_POST["name"];
$email=$_POST["email"];
$company=$_POST["company"];
$message=$_POST["message"];
//Query input menginput data kedalam tabel barang
$sql="insert into contact (no,name,email,company,message) values
('','$name','$email','$company','$message')";
//Mengeksekusi/menjalankan query diatas
$hasil=mysqli_query($kon,$sql);
//Kondisi apakah berhasil atau tidak
header("location:notif_mail.php");
?>
mohon bantuannya teman-teman
3 Jawaban:
<div>Coba passing $db nya langsung di fungsi mysqli_connect nya saja seperti ini :</div><pre>$kon = mysqli_connect($host,$user,$password, $db);</pre><div><br>Fungsi mysqli_select_db nya hapus saja.<br>Semoga berhasil.</div>
Tanggapan
terimakasih kak, namun masih sama belum bisa juga...
<div>Coba bagian button ini dikasih attribute name seperti ini :</div><pre><button name="kirim" class="btn btn-danger orange-gradient-btn fs--1" type="submit">Connect</button></pre><div><br>Kemudian bagian proses datanya diubah menjadi seperti ini :</div><pre><?php //Include file koneksi ke database include "koneksi.php";
// Ketika user telah meng-klik button dangan attribute name = kirim if(isset($_POST['kirim'])) {
//menerima nilai dari kiriman form input-barang $name = $_POST["name"]; $email = $_POST["email"]; $company = $_POST["company"]; $message = $_POST["message"];
//Mengeksekusi/menjalankan query insert ke tabel contact $hasil=mysqli_query($kon, "INSERT INTO contact (no,name,email,company,message) VALUES ('', '$name','$email','$company','$message')");
// Cek apakah query berhasil dijalankan if($hasil) { //Jika query berhasil dijalankan //Alihkan ke halaman notif_mail header("location:notif_mail.php"); } else { //Jika query gagal dijalankan // tampilkan pesan error yang datang dari database echo "Error : " . mysqli_error($kon); } }
?></pre><div>Semoga berhasil.</div>
<div><a href="https://codedoct.com/post/book/website-sederhana-untuk-pemula-menggunakan-php---crud-(create)">Mungkin bisa di jadikan referensi https://codedoct.com/post/book/website-sederhana-untuk-pemula-menggunakan-php---crud-(create)</a></div>