<?php
error_reporting (0);
$host="localhost";
$user="root";
$pass="";
$conn = mysql_connect ($host,$user,$pass) or die ("koneksi gagal");
mysql_select_db("coba", $conn);
if($_POST['simpan'])
{
$NISN=$_POST['NISN'];
$Kode_KK=$_POST['Kode_KK'];
$Nama_siswa=$_POST['Nama_siswa'];
$Alamat_siswa=$_POST['Alamat_siswa'];
$Tgl_lahir=$_POST['Tgl_lahir'];
$Foto_siswa=$_POST['Foto_siswa'];
$foto=$_FILES["Foto_siswa"]["name"];
move_uploaded_file($_FILES["Foto_siswa"]["tmp_name"], "Foto_siswa/" . $_FILES["Foto_siswa"]["name"]);
$insert="INSERT into siswa(NISN,Kode_KK,Nama_siswa,Alamat_siswa,Tgl_lahir,Foto_siswa) VALUES ('".$NISN."','".$Kode_KK."','".$Nama_siswa."','".$Alamat_siswa."','".$Tgl_lahir."','".$foto."')";
$sql=@mysql_query($insert,$conn)or die (mysql_error());
header('location:Siswa_show.php');
}
?>
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<form method="post" enctype="multipart/form-data">
<table>
<tr>
<td>NISN</td>
<td>: <input type="text" name="NISN" maxlength="20"></td>
</tr>
<tr>
<td>Kode KK</td>
<td>: <input type="text" name="Kode_KK" maxlength="20"></td>
</tr>
<tr>
<td>Nama Siswa</td>
<td>: <input type="text" name="Nama_siswa" maxlength="20"></td>
</tr>
<tr>
<td>Alamat Siswa</td>
<td>: <input type="text" name="Alamat_siswa" maxlength="20"></td>
</tr>
<tr>
<td>Tgl Lahir</td>
<td>: <input type="text" name="Tgl_lahir" maxlength="100"></td>
</tr>
<tr>
<td>Foto Siswa</td>
<td>: <input type="file" name="Foto_siswa" id="Foto_siswa" maxlength="100"></td>
</tr>
<tr>
<td colspan='2'><input type="submit" value="simpan" onclick="" name='simpan'></td>
</tr>
</table>
</form>
</body>
</html>
Contoh Code Add PHP(Dengan File Foto)
Reviewed by Syafriansyah Muhammad
on
2/27/2015
Rating:
Tidak ada komentar: