<input type="text" name="isi" id="isi">
$sql="select * from berita where isi= '??????'";
$nama="jajang";
$jam=datetime();
$headers = "From: Sistem DB";
$body = "Terdapat sebuat permintaan pelayanan data dari".echo $nama."pada jam".echo $jam;
$subject = "Request Pelayanan";
$to = "apaaja@gmail.com";
mail($to, $subject, $body, $headers)
$body merupakan bagian isi dari email yang dikirim, lantas bagaimana agar isi yang diwakili variabel $body tersebut dapat mencetak $nama dan $jam pada isi email ? sebab contoh kodingan diatas error <div class="datakamu">
<form action="<?php bloginfo('url')?>/mydata" enctype="multipart/form-data" method="post" name="data">
<script language="JavaScript"><!--
function validateForm()
{
var okSoFar=true
with (document.data)
{
if (nama.value=="" && okSoFar)
{
okSoFar=false
alert("Silahkan isi nama anda")
nama.focus()
}
if (email.value=="" && okSoFar)
{
okSoFar=false
alert("Silahkan isi Email anda")
email.focus()
}
if (No_Hp.value=="" && okSoFar)
{
okSoFar=false
alert("Silahkan No telpon anda")
No_Hp.focus()
}
if (Kota.value=="" && okSoFar)
{
okSoFar=false
alert("Silahkan isi alamat anda")
Kota.focus()
}
var foundAt = email.value.indexOf("@",0)
if (foundAt < 1 && okSoFar)
{
okSoFar = false
alert ("Masukkan alamat email yang Valid")
email.focus()
}
if (kategorihoby.value=="" && okSoFar)
{
okSoFar=false
alert("Silahkan Pilih kategori hobi")
kategorihoby.focus()
}
if (kegiatan.value=="" && okSoFar)
{
okSoFar=false
alert("Silahkan isi kegiatan anda")
kegiatan.focus()
}
if (spesifikkegiatan.value=="" && okSoFar)
{
okSoFar=false
alert("Silahkan isi detail kegiatan anda")
spesifikkegiatan.focus()
}
if (security_code.value=="" && okSoFar)
{
okSoFar=false
alert("masukkan kode sekurity")
security_code.focus()
}
if (okSoFar==true) submit();
}
}
// --></script>
<table width="100%" cellpadding="2">
<tr>
<td width="30%" align="left">Name</td>
<td width="70%"><input type="text" name="nama" size="30" id="nama" value="<?php echo $_POST['nama']?>"/></td>
</tr>
<tr>
<td width="30%" align="left">E-mail</td>
<td width="70%"><input type="text" name="email" size="30" id="email" value="<?php echo $_POST['email']?>" /><br />
</td>
</tr>
<tr>
<td width="30%" align="left">alamat</td>
<td width="70%"><input type="text" name="Kota" size="30" id="Kota" value="<?php echo $_POST['Kota']?>"/></td>
</tr>
<tr>
<td width="30%" align="left">Telpon</td>
<td width="70%"><input type="text" name="No_Hp" size="30" id="No_Hp" value="<?php echo $_POST['No_Hp']?>"/></td>
</tr>
<tr>
<td width="30%" align="left">Janis</td>
<td width="70%"><select name="type">
<option value="0">Laki-laki</option>
<option value="0">Perempuan</option>
</select></td>
</tr>
<tr>
<td width="30%" align="left" valign="top">Hoby:</td>
<td width="70%"><select name="kategorihoby" >
<option value="" size="40">====Pilih Kategori====</option>
<?php
$categories= get_categories('hide_empty=0');
foreach ($categories as $cat) {
$option = '<option value="'.$cat->cat_ID.'">';
$option .= $cat->cat_name;
$option .= ' ('.$cat->category_count.')';
$option .= '</option>';
echo $option;
}
?>
</select></td>
</tr>
<tr>
<td width="30%" align="left">kegiatan</td>
<td width="70%"><input type="text" name="kegiatan" size="30" id="kegiatan" value="<?php echo $_POST['kegiatan']?>" /></td>
</tr>
<tr>
<td width="30%" align="left" valign="top">Detail Kegiatan</td>
<td width="70%"><textarea rows="8" cols="24" name="spesifikkegiatan"><?php echo $_POST['spesifikkegiatan']?></textarea></td>
</tr>
<tr>
<td width="30%" align="left">Website</td>
<td width="70%">http://<input type="text" name="website" size="25" id="website" value="<?php echo $_POST['website']?>" /></td>
</tr>
<tr>
<td width="30%" align="left">Foto maks 125 x 125 px</td>
<td width="70%"><input type="file" name="banner" size="20"></td>
</tr>
<tr>
<td width="30%" align="left">Security Code </td>
<td width="70%"><img src="<?php bloginfo('template_url')?>/include/CaptchaSecurityImages.php?width=150&height=60&characters=5"/>
</td>
</tr>
<tr>
<td width="30%" align="left">Input Code </td>
<td width="70%"><input id="security_code" name="security_code" type="text" />
</td>
</tr>
<tr>
<td width="30%" align="left" valign="top"> </td>
<td><input type="button" class="button"
value="Pasang Iklan Gratis" name="B1" ONCLICK="javascript:validateForm()">
<input type="hidden" id="post_type" name="post_type" value="post" />
</td> </tr>
</table></form>
</div>
CREATE TABLE `materi` (
`id_materi` varchar(10) NOT NULL default '',
`nama_materi` varchar(35) NOT NULL default '',
`materi` varchar(40) NOT NULL,
`id_kelas` varchar(10) NOT NULL,
PRIMARY KEY (`id_materi`),
KEY `FK_materi` (`id_kelas`),
CONSTRAINT `FK_materi` FOREIGN KEY (`id_kelas`) REFERENCES `kelas` (`id_kelas`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Belajar Bahasa Mandarin - Data Siswa</title>
<meta name="keywords" content="Business Website, free templates, website templates, 3-column layout, CSS, XHTML" />
<meta name="description" content="Business Website, 3-column layout, free CSS template from templatemo.com" />
<style type="text/css" title="currentStyle">
@import "../media/css/demo_page.css";
@import "../media/css/demo_table_jui.css";
@import "../media/jquery-ui-1.8.4.custom.css";
</style>
<script type="text/javascript" language="javascript" src="../media/js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="../media/js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
oTable = $('#datatables').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers"
});
} );
</script>
<link rel="stylesheet" type="text/css" href="../default.css" media="screen" />
</head>
<body>
<div>
<div class="top">
<div class="header">
<div class="left"> BELAJAR BAHASA MANDARIN </div>
<div class="right">
<div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="navigation">
<a href="#" title="Home">HOME</a>
<a href="../admin/data_materi.php" title="Materi">Materi</a>
<a href="../admin/data_latihan.php" title="Latihan">Latihan</a>
<a href="../admin/data_siswa.php" title="Siswa">Siswa</a>
<div class="clearer">
<span></span>
</div>
</div>
<div class="main">
<div class="content">
<form name="tambahmateri" method="POST" entype="multipart/form-data"action="proses_tambahmateri.php" target="_self">
<table>
<tr>
<td width="150">ID Materi</td>
<td width="15">:</td>
<td>
<input type="text"name="id_materi"size="30" maxlength="15"/>*)
</td>
</tr>
<tr>
<td width="150">Nama Materi</td>
<td width="15">:</td>
<td>
<input type="text"name="nama_materi"size="30"maxlength="100"/>*)
</td>
</tr>
<tr>
<td width="150">Materi</td>
<td width="15">:</td>
<td colspan="4">
<input type="file" name="materi" size="30" maxlength="30"/>
</td>
</tr>
<tr>
<td>Kelas</td>
<td>:</td>
<td>
<select name="id_kelas">
<option value='0'>- Pilih Nama Kelas -</option>
<?php
include '../konfigurasi/koneksi.php';
$q = mysql_query("SELECT kelas FROM kelas ORDER BY kelas ASC;");
while ($row1 = mysql_fetch_array($q)) {
echo "<option value=$row1[id_kelas]>$row1[kelas]</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="3"> *) isikan secara lengkap <br/>
</td>
</tr>
<tr>
<th colspan='6'>
<input type="submit" name="Simpan" value="Simpan"/>
<a href="insert_materi.php">
<input type="button" value="Batal"/>
</a>
</th>
</tr>
</table>
</form>
<tr>
<td colspan="2" valign=top>
<table id = "datatables" class ="display" width="100%" border="0" cellspacing="0" cellpadding="5">
<thead>
<tr>
<th>ID Materi</th>
<th>Nama Materi</th>
<th>Kelas</th>
<th>Edit</th>
<th>Hapus</th>
</tr>
</thead>
<tbody>
<?php
include '../konfigurasi/koneksi.php';
$view = mysql_query("SELECT kelas.kelas, materi.*
FROM bahasa_mandarin.materi
INNER JOIN bahasa_mandarin.kelas
ON (materi.id_kelas = kelas.id_kelas)
ORDER BY kelas.kelas ASC;");
while ($row = mysql_fetch_array($view)) {
echo"<tr><td>";
echo $row['id_materi'];
echo "</td><td>";
echo $row['nama_materi'];
echo "</td><td><center>";
echo $row['kelas'];
echo"</td><td>";
echo "<a href=edit_materi.php?id_materi=$row[id_materi]>";
echo"<img src='../gambar/edit.png' >";
echo"</a>";
echo "</td><td><center>";
echo "<a href=\"../admin/proses_hapusmateri.php?id_materi=$row[id_materi]\" onclick=\"return confirm('Anda yakin akan mengapus data materi $row[nama_materi]?');\">";
echo "<img src='../gambar/delete.gif'>";
echo "</a>";
echo "</td>";
}
?>
</tbody>
</table>
</td>
</tr>
</div>
<div class="sidenav">
<h2>FlexCMS</h2>
<ul>
<li><a href="#" title="Home">Home </a></li>
<li><a href="#" title="Downloads">Forest
Green </a></li>
<li><a href="http://www.flexcms.co.uk/FlexCMS_Documentation.aspx" title="Documentation">Trees </a></li>
<li><a href="#" title="FAQs">About Us </a></li>
<li><a href="http://www.flexcms.co.uk/FlexCMS_ContactUs.aspx" title="Contact Us">Contact Us </a></li>
</ul>
<h2>Membership</h2>
<ul>
<li><a href="#">Login / Register</a></li>
<li><a href="#">Forgot password?</a></li>
</ul>
<h2>FlexCMS Bespoke versions </h2>
<ul>
<li><a href="http://www.giant-systems.co.uk/">FlexCMS
</a></li>
<li><a href="http://www.giant-systems.co.uk/Ecommerce.aspx">FlexEcommerce</a></li>
<li><a href="http://www.giant-systems.co.uk/casestudies.aspx">FlexCMS
portal server </a></li>
<li><a href="http://www.giant-systems.co.uk/casestudies.aspx">FlexCMS
Intranet </a></li>
</ul>
<br />
<br />
</div>
<div class="clearer"><span></span></div>
</div>
<div class="footer">© Ilana Fedelia - <a href ="http://www.usd.ac.id">Universitas Sanata Dharma Yogyakarta </a> 2012- Design by <a href="http://www.giant-systems.co.uk" title="Giant Systems Web design">Giant Systems Ltd</a>
</div>
</div>
</div>
<div style="font-size: 0.8em; text-align: center; margin-top: 1em; margin-bottom: 1em;">
Design downloaded from <a href="http://www.freewebtemplates.com/">Free
Templates</a> - your source for free web templates<br />
Supported by <a href="http://www.hosting24.com/" target="_blank">Hosting24.com</a>
</div>
</body></html>
<?php
session_start();
include '../konfigurasi/koneksi.php';
if (empty($_POST[id_materi]) || empty($_POST[nama_materi])) {
echo"<script language='javascript'>alert('Isikan semua form yang bertanda bintang (*)');
window.location = '../admin/insert_materi.php'</script>";
} elseif ($_POST[kelas] == '') {
echo "<script language='javascript'>alert('Isikan semua form yang bertanda bintang (*)');
window.location = '../admin/insert_materi.php'</script>";
} else {
$numRowsIdMateri = mysql_num_rows(mysql_query("SELECT id_materi FROM materi WHERE id_materi = '$_POST[id_materi]'"));
if ($numRowsIdMateri > 0) {
echo "<script language='javascript'>alert('ID materi sudah digunakan,masukkan id materi yang benar.');
window.location = '../admin/insert_materi.php'</script>";
} else {
if ($_FILES['materi']['size'] > 0 && $_FILES['materi']['error'] == 00) {
//membaca nama file
$fileName = $_FILES['materi']['name'];
//membaca size file
$_fileSize = $_FILES['materi']['size'];
//membaca nama file temporary
$tempName = $_FILES['materi']['tmp_name'];
//membuka atau membongkar file
$fp = fopen($tempName, 'r');
//membaca isi dari file, membaca kode binernya
$file_content = fread($fp, filesize($tempName) or die("Error:cannot read file"));
//menyimpan kode binernya ke variabel, ini yang akan disimpan di database
$file_content = mysql_real_escape_string($file_content) or die("error: cannot read file");
//menutup file
fclose($fp);
$query = "insert into materi (id_materi,nama_materi,materi,id_ujian)values('$_POST[id_materi]','$_POST[nama_materi],'$file_content',$_POST[id_kelas])";
$re=mysql_query($query)or die("insert gagal");
echo"<script language='javascript'>alert('Materi $_POST[nama_materi] untuk kelas = $_POST[kelas] berhasil ditambahkan/disimpan');
window.location='../admin/data_materi.php'</script>";
}
}
}
?>