Below are the code for the page.
Code: Select all
<?php
if(isset($_POST['submitted'])) {
include('connect.php');
$id=$_POST['id'];
$negeri=$_POST['negeri'];
$daerah=$_POST['daerah'];
$pkg=$_POST['pkg'];
$kod_sekolah=$_POST['kod_sekolah'];
$nama_sekolah=$_POST['nama_sekolah'];
$ptj=$_POST['ptj'];
$server=$_POST['server'];
$pc=$_POST['pc'];
$nb=$_POST['nb'];
$mono_laser=$_POST['mono_laser'];
$color_laser=$_POST['color_laser'];
$dot_matrix=$_POST['dot_matrix'];
$lcd=$_POST['lcd'];
$set_lan=$_POST['set_lan'];
$jumlah_kos=$_POST['jumlah_kos'];
$dibayar=$_POST['dibayar'];
$tanggungan=$_POST['tanggungan'];
if($negeri){
if($daerah){
if($pkg){
if($kod_sekolah){
$q1=mysqli_query("SELECT * FROM schools where kod_sekolah = '".$_POST['kod_sekolah']."'");
$q2=mysqli_fetch_object($dbcon,$q1);
if($q2->kod_sekolah == $_POST['kod_sekolah']){
die('<br><br>There is already "'.$q2->kod_sekolah.'" in the database, please choose another Kod Sekolah.');
}
if($nama_sekolah){
$sqlinsert="INSERT INTO schools (id, negeri, daerah, pkg, kod_sekolah, nama_sekolah, ptj, server, pc, nb, mono_laser,
color_laser, dot_matrix, lcd, set_lan, jumlah_kos, dibayar, tanggungan)
VALUES ('$id','$negeri', '$daerah', '$pkg', '$kod_sekolah', '$nama_sekolah', '$ptj', '$server', '$pc', '$nb',
'$mono_laser',
'$color_laser','$dot_matrix', '$lcd', '$set_lan', '$jumlah_kos', '$dibayar', '$tanggungan')";
if(!mysqli_query($dbcon, $sqlinsert)){
die('error inserting new record');
}
$errormsg = "1 Record Has Been Inserted";
}
else
$errormsg="Please Complete Nama Sekolah Field";
}
else
$errormsg="Please Complete Kod Sekolah Field";
}
else
$errormsg="Please Complete PKG Field";
}
else
$errormsg="Please Complete Daerah Field";
}
else
$errormsg="Please Complete Negeri Field";
}
?>
If it helps this are the code for connect.php and the database
Code: Select all
<?php
$dbcon=mysqli_connect("localhost","root","", "project");
?>