How To Create Student Input Data Form Using PHP-MySQL
What Will I Learn?
- You will learn how to create simple form
- You will learn How To Create Student Input Data Form
- You will learn how to conect PHP-MySQL
Requirements
- you should be able to programming basic PHP
- You should be able to program HTML
- you should be able to SQL query
Difficulty
- Basic
Tutorial Contents
now universities already have their own website, they have also provided a new student registration system online, not only at universities, internacionalonal schools have also established websites to facilitate students in obtaining information. now if you want to enroll in a university or school, you just need to fill out a form that they have provided on their website. this time I will teach how to make a student data input form using PHP.
- the first step is to open the text editor.
i use notepad++ - then type the program below in your text editor.
<!DOCTYPE html>
<html>
<head>
<title>Ajax Jquery - Belajarphp.net</title>
</head>
<body>
<form method="post" action="simpan.php">
<table>
<tr><td>NIM</td><td><input type="text" onkeyup="isi_otomatis()" name="nim"></td></tr>
<tr><td>NAMA</td><td><input type="text" name="nama"></td></tr>
<tr><td>JENIS KELAMIN</td><td>
<input type="radio" name="jenis_kelamin" value="L">Laki Laki
<input type="radio" name="jenis_kelamin" value="P">Perempuan
</td></tr>
<tr><td>JURUSAN</td><td>
<select name="jurusan">
<option value="TEKNIK INFORMATIKA">TEKNIK INFORMATIKA</option>
<option value="TEKNIK MESIN">TEKNIK MESIN</option>
<option value="TEKNIK KIMIA">TEKNIK KIMIA</option>
</select>
</td></tr>
<tr><td>ALAMAT</td><td><input type="text" name="alamat"></td></tr>
<tr><td colspan="2"><button type="submit" value="simpan">SIMPAN</button></td></tr>
</table>
</form>
</body>
</html>
- the above program is to design the input form that we will display on our web page.
- the next step is to make a connection to the database. type the script below in your text editor and save it with the name simpan.php
<?php
include 'koneksi.php';
// menyimpan data kedalam variabel
$nim = $_POST['nim'];
$nama = $_POST['nama'];
$jurusan = $_POST['jurusan'];
$jenis_kelamin = $_POST['jenis_kelamin'];
$alamat = $_POST['alamat'];
// query SQL untuk insert data
$query="INSERT INTO mahasiswa SET nim='$nim',nama='$nama',jurusan='$jurusan',jenis_kelamin='$jenis_kelamin',alamat='$alamat'";
mysqli_query($koneksi, $query);
// mengalihkan ke halaman index.php
header("location:index.php");
?>
- query above serves to enter data that has been entered into our database.
- save both files above in the same folder.
- save it on the XAMPP / htdochs folder / then name the folder you created.
- okay after creating the second file above then we try to run the form we have created, but first run the first APACHE and MySQL server in XAMPP application.
- then we will run our form by opening the browser then write our file address in the search field as shown below.
display the form when we run
- then we fill the form and press the save button.
- then we open our database, whether the data we enter has been stored ...?
- okay student form input we have successfully created
- please try and follow this tutorial carefully I sure will succeed.
Posted on Utopian.io - Rewarding Open Source Contributors
@voters, Contribution to open source project, I like you and upvote.
I like your contribution to open source project, so I upvote to support you.
Thank you for your contribution, yet it cannot be approved because it does not follow the Utopian Rules.
A tutorial is supposed to explain things in details. You simply placed code and asked the readers to use this. This is not what a tutorial is about.
You can contact us on Discord.
[utopian-moderator]