1. Buat File koneksi.php
<?php
$host = "localhost";
$user = "root";
$password = "";
$database = "databasename";
$link = mysql_connect("localhost","root","") or die (" Koneksi database gagal ");
$db = mysql_select_db($database, $link) or die(" Database belum dipilih");
?>
2. Buat file simpan.php
<?php
include 'koneksi.php';
// menyimpan data
$nim = $_POST['nim'];
$nama = $_POST['nama'];
$jurusan = $_POST['jurusan'];
$jenis_kelamin = $_POST['jenis_kelamin'];
$alamat = $_POST['alamat'];
// query insert
$query="Insert Into mahasiswa Set nim='$nim',nama='$nama',jurusan='$jurusan',jenis_kelamin='$jenis_kelamin',alamat='$alamat'";
mysql_query($query);
?>
3. Membuat Inputan : input.php
<!DOCTYPE html>
<html>
<head>
<title>Pengisian data mahasiswa </title>
</head>
<body>
<form method="post" action="simpan.php" style="padding: 15px 15px; width: 25%; margin: auto; background-color: #CC9900">
<h3 align="center">Pengisian Data Mahasiswa </h3>
<table>
<tr><td>NIM</td><td>:</td><td><input type="text" name="nim" ></td></tr>
<tr><td>NAMA</td><td>:</td><td><input type="text" name="nama"></td></tr>
<tr>
<td>JENIS KELAMIN</td><td>:</td>
<td><input type="radio" name="jenis_kelamin" value="Laki-Laki">Laki - Laki
<input type="radio" name="jenis_kelamin" value="Perempuan" >Perempuan</td>
</tr>
<tr><td>JURUSAN</td><td>:</td><td><input type="text" name="jurusan"></td></tr>
<tr><td>ALAMAT</td><td>:</td><td><input type="textarea" name="alamat"></td> </tr>
<tr>
<td></td>
<td></td>
<td colspan="2"><button type="submit" value="simpan">SIMPAN</button></td>
</tr>
</table>
</form>
</div>
</body>
</html>