gambar 1 tabel pendaftar
DOWNLOAD
setelah membuat tabel pendaftar, kita akan membuat koneksi ke database dengan script php,:
konek.php
$db="smaku";
$sambung=mysql_connect("localhost","root","");
$pilih_db=mysql_select_db($db,$sambung);
//if($pilih_db){echo"OK";}
?>
$sambung=mysql_connect("localhost","root","");
$pilih_db=mysql_select_db($db,$sambung);
//if($pilih_db){echo"OK";}
?>
setelah itu buat form pendaftarannya,
finputpendaftar.php
==========================scriptnya=======================================
===================================================================
setelah itu kita buat file yg berisi script menyimpan data ke database..
inputpendaftar.php
$tahun=date("Y");
?>if(isset($_POST['simpan'])){
include "../konek.php";
//$no = $_POST['no'];
$nilai=$_POST['nilai'];
$email=$_POST['email'];
$alamat=$_POST['alamat'];
$tahun=$_POST['tahun'];
$jml=$_POST['jml'];
$pass=$_POST['pass'];
$pass2=$_POST['pass2'];
$nama = $_POST['nama'];
//$ktgr=$_POST['select'];
$fileName = $_FILES['foto']['name']; //get the file name
$fileSize = $_FILES['foto']['size']; //get the size
$fileError = $_FILES['foto']['error']; //get the error when upload
$uploaddir='../img/';
$lokasi=$uploaddir.$fileName;
if(trim($nama=='') or trim($nilai=='') or trim($alamat=='') or trim($pass=='') or trim($fileName=='') or trim($pass!= $pass2)){
echo"Data Gagal disimpan, pastikan semua data sudah terisi dengan benar atau periksa kecocokan password anda ..! ";
}
else{
//echo "Success!";
$q = "INSERT into pendaftar VALUES('','$nama','$nilai','$email','$alamat','$tahun','$jml','','$fileName','../img/$fileName','$pass','')"; //insert image property to database
mysql_query($q);
if($q){
$move = move_uploaded_file($_FILES['foto']['tmp_name'],$lokasi); //save image to the folder
if($move){
echo"";
} else { echo "
Gambar / foto wajib diisi atau diupload !"; }
}
}
}
?>
?>if(isset($_POST['simpan'])){
include "../konek.php";
//$no = $_POST['no'];
$nilai=$_POST['nilai'];
$email=$_POST['email'];
$alamat=$_POST['alamat'];
$tahun=$_POST['tahun'];
$jml=$_POST['jml'];
$pass=$_POST['pass'];
$pass2=$_POST['pass2'];
$nama = $_POST['nama'];
//$ktgr=$_POST['select'];
$fileName = $_FILES['foto']['name']; //get the file name
$fileSize = $_FILES['foto']['size']; //get the size
$fileError = $_FILES['foto']['error']; //get the error when upload
$uploaddir='../img/';
$lokasi=$uploaddir.$fileName;
if(trim($nama=='') or trim($nilai=='') or trim($alamat=='') or trim($pass=='') or trim($fileName=='') or trim($pass!= $pass2)){
echo"Data Gagal disimpan, pastikan semua data sudah terisi dengan benar atau periksa kecocokan password anda ..! ";
}
else{
//echo "Success!";
$q = "INSERT into pendaftar VALUES('','$nama','$nilai','$email','$alamat','$tahun','$jml','','$fileName','../img/$fileName','$pass','')"; //insert image property to database
mysql_query($q);
if($q){
$move = move_uploaded_file($_FILES['foto']['tmp_name'],$lokasi); //save image to the folder
if($move){
echo"";
} else { echo "
Gambar / foto wajib diisi atau diupload !"; }
}
}
}
?>
kemudian jalankan...
semoga berhasil.... good luck
script lengkapnya dowload disini
oke gan...
ReplyDelete