Aplikasi Sederhana Input Data mahasiswa-WPS Office

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Aplikasi sederhana input Data mahasiswa berbasis web

1. Buat file HTML untuk tampilan frontend (index.html):

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Data Mahasiswa</title>

<link rel="stylesheet" href="style.css">

</head>

<body>

<h1>Data Mahasiswa</h1>

<form action="process.php" method="post">

<label for="nama">Nama:</label>

<input type="text" name="nama" required>

<label for="nim">NIM:</label>

<input type="text" name="nim" required>

<button type="submit">Tambah Mahasiswa</button>

</form>

<h2>Daftar Mahasiswa</h2>

<ul>
<?php include 'display.php'; ?>

</ul>

</body>

</html>

2. Buat file CSS untuk styling (style.css):

body {

font-family: Arial, sans-serif;

margin: 20px;

form {

margin-bottom: 20px;

label {

display: block;

margin-bottom: 5px;

button {

padding: 5px 10px;

cursor: pointer;

ul {
list-style-type: none;

padding: 0;

li {

margin-bottom: 10px;

3. Buat file PHP untuk memproses data (process.php):

<?php

$servername = "localhost";

$username = "root";

$password = "";

$dbname = "database_mahasiswa";

$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

if ($_SERVER["REQUEST_METHOD"] == "POST") {

$nama = $_POST["nama"];

$nim = $_POST["nim"];

$sql = "INSERT INTO mahasiswa (nama, nim) VALUES ('$nama', '$nim')";


if ($conn->query($sql) === TRUE) {

echo "Mahasiswa berhasil ditambahkan";

} else {

echo "Error: " . $sql . "<br>" . $conn->error;

$conn->close();

?>

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy