coding tidak tersambung ke database

boleh minta bantuan nya ga dimana salah nya , soalnya coding nya ga bisa ke submit kedalam daatabase

ini file coding nya

a.pngb.pngd.pngc.png

<!DOCTYPE html>
<html>
<head>
  <meta class="row" align-items-end charset="utf-8">
  <title>Pendaftaran Mahasiswa Baru</title>
</head>
<body>
  <!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

 <style type="text/css">
  .border_blue {border: 1px solid lavenderblush;}
  .border_grey {border: 1px solid grey;}
 </style>
 <title>Pendaftaran Online Mahasiswa Baru</title>
</div>
  <h1 class="text-center">PENDAFTARAN ONLINE MAHASISWA BARU</h1>
 <form method="post" action="http://localhost/php/save.php">
<form>
  <div class="form-group col-6">
    <label for="inputNama">Nama</label>
    <input type="text" class="form-control" id="nama" placeholder=" ">
  </div>
  <div class="form-group col-6">
    <label for="inputNama">Asal Sekolah</label>
    <input type="text" class="form-control" id="asal_sekolah" placeholder=" ">
  </div>

   <fieldset class="form-group row col-6">
    <legend class="col-form-label col-sm-2 float-sm-left pt-0">Jenis Kelamin</legend>
    <div class="col-sm-10">
      <div class="form-check">
        <input class="form-check-input" type="radio" name="gridRadios" value="option1" checked>
        <label class="form-check-label" for="gridRadios1">
          Laki-Laki
        </label>
      </div>
      <div class="form-check">
        <input class="form-check-input" type="radio" name="gridRadios" value="option2">
        <label class="form-check-label" for="gridRadios2">
          Perempuan
        </label>
      </div>
  </fieldset>
  <div class="form-group col-6">
    <label for="inputTempatPertandingan">Tempat Lahir</label>
    <input type="text" class="form-control" id="tempat_lahir" placeholder=" ">
  </div>
  <div class="form-group col-6">
      <label for="inputTempatPertandingan">Tanggal_Lahir</label>
      <input type="text" name="tanggal" id="datepicker" placeholder=" ">
  </div>
  <div class="form-group col-6">
    <label for="inputNama">Nilai Sekolah</label>
    <input type="text" class="form-control" id="nilai_sekolah" placeholder=" ">
  </div>
  <div class="form-group col-6">
  <label for="comment">Komentar</label>
  <textarea class="form-control" rows="5" id="komentar"></textarea>
  </div>
  <button type="submit" class="btn btn-primary">Submit</button>
</form>
<script>
    //format tanggal
    var picker = new Pikaday({
        field: document.getElementById('datepicker'),
        format: 'D/M/YYYY',
        toString(date, format) {
            // you should do formatting based on the passed format,
            // but we will just return 'D/M/YYYY' for simplicity
            const day = date.getDate();
            const month = date.getMonth() + 1;
            const year = date.getFullYear();
            return `${day}-${month}-${year}`;
        },
        parse(dateString, format) {
            // dateString is the result of `toString` method
            const parts = dateString.split('/');
            const day = parseInt(parts[0], 10);
            const month = parseInt(parts[1], 10) - 1;
            const year = parseInt(parts[2], 10);
            return new Date(year, month, day);
        }
    });
</script>

<script type="text/javascript">
    // Jquery Dependency
    $('.money').mask('000.000.000', {
        reverse: true
    });
</script>
</html>
avatar sitinurazizah
@sitinurazizah

6 Kontribusi 1 Poin

Diperbarui 3 tahun yang lalu

1 Jawaban:

<div>Coba script koneksinya diubah seperti ini aja :<br><br></div><pre>&lt;?php $hostname = "localhost"; $username = "root"; $password = ""; $database = "form1";

try{ $db = new PDO("mysql:host=$hostname;dbname=$database", $username, $database); } catch(PDO::Exception $e){ echo "Gagal koneksi ke database! Error: " . $e-&gt;getMessage(); }</pre><div><br>Sebagai saran, coba kamu pelajari perbedaan single quote dan double quote :<br>- <a href="https://papaiksan.wordpress.com/2012/09/01/perbedaan-single-quoted-dan-double-quoted-pada-operasi-string-php/">https://papaiksan.wordpress.com/2012/09/01/perbedaan-single-quoted-dan-double-quoted-pada-operasi-string-php/</a><br>- <a href="https://www.dumetschool.com/blog/Perbedaan-Double-Quote-Dan-One-Quote-Di-Dalam-PHP">https://www.dumetschool.com/blog/Perbedaan-Double-Quote-Dan-One-Quote-Di-Dalam-PHP</a><br>- <a href="https://blog.sibudi.net/php-single-quote-vs-double-quote/">https://blog.sibudi.net/php-single-quote-vs-double-quote/</a><br><br>Semoga berhasil.</div>

avatar ahanafi
@ahanafi

815 Kontribusi 554 Poin

Dipost 3 tahun yang lalu

Tanggapan

masih erorr kak , erorr nya sama seperti sebelumnya

Login untuk ikut Jawaban