Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_POST['submit'])) {
- require_once("koneksi.php");
- $sql = $conn->prepare("INSERT INTO tbl_mahasiswa (nimmhs,namamhs,alamatmhs,teleponmhs,jurusanmhs) VALUES (?, ?, ?, ?, ?)");
- $nimmhs=$_POST['nimmhs'];
- $namamhs = $_POST['namamhs'];
- $alamatmhs= $_POST['alamatmhs'];
- $teleponmhs= $_POST['teleponmhs'];
- $jurusanmhs= $_POST['jurusanmhs'];
- $sql->bind_param("sssss", $nimmhs, $namamhs, $alamatmhs, $teleponmhs, $jurusanmhs);
- if($sql->execute()) {
- $success_message = "Input Data Berhasil";
- } else {
- $error_message = "Ada masalah dengan Penginputan";
- }
- $sql->close();
- $conn->close();
- }
- ?>
- <html>
- <head>
- <link href="style.css" rel="stylesheet" type="text/css" />
- <style>
- .tbl-qa{border-spacing:0px;border-radius:4px;border:#6ab5b9 1px solid;}
- </style>
- <title>Input Data Mahasiswa</title>
- </head>
- <body>
- <h1>CRUD PHP MySQLi questkomputer.com</h1>
- <?php if(!empty($success_message)) { ?>
- <div class="success message"><?php echo $success_message; ?></div>
- <?php } if(!empty($error_message)) { ?>
- <div class="error message"><?php echo $error_message; ?></div>
- <?php } ?>
- <form id="frmUser" method="post" action="">
- <div class="button_link"><a href="index.php"> List Mahasiswa </a></div>
- <table border="0" cellpadding="10" cellspacing="0" width="500" align="center" class="tbl-qa">
- <thead>
- <tr>
- <th colspan="2" class="table-header">Input Data Mahasiswa</th>
- </tr>
- </thead>
- <tbody>
- <tr class="table-row">
- <td><label>NIM</label></td>
- <td><input type="text" name="nimmhs" class="txtField"></td>
- </tr>
- <tr class="table-row">
- <td><label>Nama</label></td>
- <td><input type="text" name="namamhs" class="txtField"></td>
- </tr>
- <tr class="table-row">
- <td><label>Alamat</label></td>
- <td><input type="text" name="alamatmhs" class="txtField"></td>
- </tr>
- <tr class="table-row">
- <td><label>Telepon</label></td>
- <td><input type="text" name="teleponmhs" class="txtField"></td>
- </tr>
- <tr class="table-row">
- <td><label>Jurusan</label></td>
- <td><input type="text" name="jurusanmhs" class="txtField"></td>
- </tr>
- <tr class="table-row">
- <td colspan="2"><input type="submit" name="submit" value="Submit" class="demo-form-submit"></td>
- </tr>
- </tbody>
- </table>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement