Postingan lainnya
teman-teman ketika tombol submit ditekan data tidak masuk ke database maupun tampilan form
tambah data
<!-- Modal body -->
<form methode="POST" action="" enctype="multipart/form-data">
<section class="base">
<div>
<p>Nama Dokter</p>
<input type="text" name="username" class="form-control">
<p>Email</p>
<input type="text" name="email" class="form-control">
<p>Alamat</p>
<input type="text" name="alamat" class="form-control">
<p>Nomor Telephone</p>
<input type="number" name="no_hp" class="form-control">
<button type="submit" class="btn btn-primary" name="addnew">Submit</button>
</div>
</form>
function
<?php
include "mysql_mysqli.inc.php";
session_start();
//koneksi
$conn = mysqli_connect("localhost","root","","db_komkordik");
if(mysqli_connect_errno()) {
echo mysqli_connect_error();
}
function base_url($url = null) {
$base_url = "http://localhost/komkordik";
if($url != null) {
return $base_url."/".$url;
} else {
return $base_url;
}
}
//TAMBAH DATA
if(isset($_POST['addnew'])){
$username = $_POST['username'];
$email = $_POST['email'];
$alamat = $_POST['alamat'];
$no_hp = $_POST['no_hp'];
$addtotable = mysqli_query($conn, "insert into kom_dokter (username,email,alamat,no_hp)
values ('$username','$email','$alamat','$no_hp')");
if($addtotable){
header('location:index.php');
} else {
echo 'Gagal';
header('location:index.php');
}
}
?>
0
1 Jawaban:
Jawaban Terpilih
<div>Hallo, bantu jawab yaa, kayanya agan salah nulis nama atribut form-nya deh.<br>Bagian ini :</div><pre><form methode="POST" action="" enctype="multipart/form-data"></pre><div>itu ada attribute "methode", coba diubah menjadi "method" agar data yang dikirim melalui form dapat dibaca oleh PHP. Untuk informasi lebih lanjutnya dapat dipelajari di link berikut <a href="https://www.w3schools.com/html/html_forms_attributes.asp">https://www.w3schools.com/html/html_forms_attributes.asp</a><br>Semoga berhasil.</div>
1