Hello im a beginner at php, i have a code that i want to store form data (post method) to a database, i've research in PHP: Inserting Values from the Form into MySQL , but still no luck. Here is my code
<?php
if(isset($_POST["smp"])){
$pd = $_POST["perda"];
$pg = $_POST["pergub"];
$dpaa = $_POST["dpa"];
$nm = $_POST["nama"];
$nm1 = $_POST["nama1"];
$nm2 = $_POST["nama2"];
$nm3 = $_POST["nama3"];
$nm4 = $_POST["nama4"];
$nm5 = $_POST["nama5"];
$nm6 = $_POST["nama6"];
$tp = $_POST["tanggalp"];
$tb = $_POST["tanggalb"];
$td = $_POST["tanggald"];
$tdb = $_POST["tanggaldb"];
$kp = $_POST["keperluan"];
$tk = $_POST["tingkat"];
$mk = $_POST["maksud"];
$tj = $_POST["tujuan"];
$akt = $_POST["angkut"];
$tib = $_POST["tiba"];
$nobb = $_POST["nob"];
$nopp = $_POST["nop"];
$nokk = $_POST["nok"];
$ak = $_POST["akun"];
$ln = $_POST["lain"];
$sql = "INSERT INTO tb_spj (nomor, tipe, pda, pgb, dpa, pg_tugas, rc_tugas, pg_ikut1, rc_ikut1, pg_ikut2, rc_ikut2, pg_ikut3, rc_ikut3, pg_ikut4, rc_ikut4, pg_ikut5, rc_ikut5, tgl_skp, tgl_br, tgl_dt, tgl_db, kpl, tk_spj, mk, tuju, angkutan, pg_tuju, tiba, no_bku, no_prog, no_kgt, akn, ket) VALUES ('$c', 'Dalam Daerah', '$pd', '$pg', '$dpaa', '$nm', ' ', '$nm1', ' ', '$nm2', ' ', '$nm3', ' ', '$nm4', ' ', '$nm5', ' ', '$tp', '$tb', '$td', '$tdb', '$kp', '$tk', '$mk', '$tj', '$akt', '$nm6', '$tib', '$nobb', '$nokk', '$ak', '$ln')";
$conn->query($sql);
$c++;}
?>
I am so confused right now, please help which code i do wrong
Hello im a beginner at php, i have a code that i want to store form data (post method) to a database, i've research in PHP: Inserting Values from the Form into MySQL , but still no luck. Here is my code
<?php
if(isset($_POST["smp"])){
$pd = $_POST["perda"];
$pg = $_POST["pergub"];
$dpaa = $_POST["dpa"];
$nm = $_POST["nama"];
$nm1 = $_POST["nama1"];
$nm2 = $_POST["nama2"];
$nm3 = $_POST["nama3"];
$nm4 = $_POST["nama4"];
$nm5 = $_POST["nama5"];
$nm6 = $_POST["nama6"];
$tp = $_POST["tanggalp"];
$tb = $_POST["tanggalb"];
$td = $_POST["tanggald"];
$tdb = $_POST["tanggaldb"];
$kp = $_POST["keperluan"];
$tk = $_POST["tingkat"];
$mk = $_POST["maksud"];
$tj = $_POST["tujuan"];
$akt = $_POST["angkut"];
$tib = $_POST["tiba"];
$nobb = $_POST["nob"];
$nopp = $_POST["nop"];
$nokk = $_POST["nok"];
$ak = $_POST["akun"];
$ln = $_POST["lain"];
$sql = "INSERT INTO tb_spj (nomor, tipe, pda, pgb, dpa, pg_tugas, rc_tugas, pg_ikut1, rc_ikut1, pg_ikut2, rc_ikut2, pg_ikut3, rc_ikut3, pg_ikut4, rc_ikut4, pg_ikut5, rc_ikut5, tgl_skp, tgl_br, tgl_dt, tgl_db, kpl, tk_spj, mk, tuju, angkutan, pg_tuju, tiba, no_bku, no_prog, no_kgt, akn, ket) VALUES ('$c', 'Dalam Daerah', '$pd', '$pg', '$dpaa', '$nm', ' ', '$nm1', ' ', '$nm2', ' ', '$nm3', ' ', '$nm4', ' ', '$nm5', ' ', '$tp', '$tb', '$td', '$tdb', '$kp', '$tk', '$mk', '$tj', '$akt', '$nm6', '$tib', '$nobb', '$nokk', '$ak', '$ln')";
$conn->query($sql);
$c++;}
?>
I am so confused right now, please help which code i do wrong
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.