I'm expecting the value that I inserted at web page stored in the databaase. The error shown before tell me the fields are empty still empty even I already put something to all of them.
These are the coding that I use before
KONEKSI.PHP
<?php
$dbhost = "localhost";
$dbuser = "";
$dbpass = "";
$dbname = "";
mysql_connect($dbhost, $dbuser, $dbpass) or die
("connection to MySQL failed!");
mysql_select_db($dbname);
$tanggal = date("Y-m-d H:i:s");
?>
==========================================================
FORUM.PHP (html file)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>..:: Welcome to Babilonia Website ::..</title>
<LINK href="./files/font.css" type=text/css rel=stylesheet>
<LINK href="./files/corpweb.css" type=text/css rel=stylesheet>
<LINK href="./files/corpweb2.css" type=text/css rel=stylesheet>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#0066FF">
<table width="800" border="1" cellspacing="1" cellpadding="1" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<tr>
<td valign="top">
<?
include ("header.php");
?>
</td>
</tr>
<tr>
<td>
<table width="800" border="0" cellspacing="1" cellpadding="1">
<tr>
<td width="250" valign="top" bgcolor="#FFFFFF">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
<tr>
<td bgcolor="#CCCCCC" align="center">
<a class=mainmenulink onMouseOver="this.className='mainmenulinkover'" onMouseOut="this.className='mainmenulink'" href="forum.php"><font size="4">Forum</font></a></font></td>
</tr>
<td bgcolor="#CCCCCC" align="center"><hr></td>
<tr>
<td bgcolor="#CCCCCC" align="center">
<a class=mainmenulink onMouseOver="this.className='mainmenulinkover'" onMouseOut="this.className='mainmenulink'" href="
mailto:buitenzorgcity@hotmail.com"><font size="4">Contact Us</font></a>
</td>
</tr>
</table>
</td>
<td width="550" valign="top" bgcolor="#FFFFFF">
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td bgcolor="#93CDF5">
<?
require("koneksi.php");
$data2=mysql_query("select * from forum order by id");
$jumlah=mysql_num_rows($data2);
$limit = 10;
if (empty($offset))
{
$offset = 0;
}
$query = "select * from forum ORDER BY id DESC LIMIT $offset, $limit";
$result = mysql_query($query);
// Pembagian halaman dimulai
$halaman = intval($jumlah/$limit);
if ($jumlah%$limit)
{
$halaman++;
}
for ($i=1; $i<=$halaman; $i++)
{
$newoffset=$limit*($i-1);
if ($offset!=$newoffset)
{
echo "[<a href=\"forum.php?offset=$newoffset\">$i</a>]";
}
else
{
echo "[$i]";
}
}
// Pembagian halaman selesai
?>
</td>
</tr>
<tr>
<td>
<?php
while ($data = mysql_fetch_array($result)) {
echo ("
<br>
<b><u>$data[penulis]</b></u>, <b>$data[title]</b>, <br> $data[tanggal] <br>
$data[content]<br>
<hr>
");
}
?>
</td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form method="post" action="gbinput.php">
<tr>
<td align="center" colspan="3" bgcolor="#93CDF5">
<span class="teks10_normal"><span class="style1">Give Your Post or Comment</span></span></td>
</tr>
<tr>
<td align="center" colspan="3"> </td>
</tr>
<tr>
<td><span class="teks10_normal"><span class="style1">Title</span></span></td>
<td><div align="center"><span class="teks10_normal"><span class="style1">:</span></span></div></td>
<td><input type="text" name="title" size="48"></td>
</tr>
<tr>
<td><span class="teks10_normal"><span class="style1">Your Name</span></span></td>
<td><div align="center"><span class="teks10_normal"><span class="style1">:</span></span></div></td>
<td><input type="text" name="penulis" size="48"></td>
</tr>
<tr>
<td><span class="teks10_normal"><span class="style1">Content</span></span></td>
<td><div align="center"><span class="teks10_normal"><span class="style1">:</span></span></div></td>
<td rowspan="4"><textarea rows="4" name="content" cols="36"></textarea>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="3" align="center"><br>
<input type="submit" value="Submit" name="submit">
<input type="reset" value="Clear" name="Clear">
</td>
</tr>
</form>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?
include ("footer.php");
?>
</body>
</html>
=======================================================
GBINPUT.php
<?php
require("koneksi.php");
if (empty($title) || empty($penulis) || empty($content))
{ $kesalahan = TRUE; }
if (!$kesalahan)
{
$perintah = "INSERT INTO forum (title, penulis, content, tanggal)
VALUES ('$title','$penulis','$content','$tanggal')";
$hasil = mysql_query($perintah);
if($hasil)
{
header("Location:forum.php");
}
}
else
{
echo("
<html>
<head>
<title>Error</title>
<LINK href=\"./files/font.css\" type=text/css rel=stylesheet>
<LINK href=\"./files/corpweb.css\" type=text/css rel=stylesheet>
<LINK href=\"./files/corpweb2.css\" type=text/css rel=stylesheet>
</head>
<body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">
<table width=\"800\" border=\"1\" cellspacing=\"1\" cellpadding=\"1\" align=\"center\">
<tr>
<td>
");
include ("header.php");
echo("
</td>
</tr>
<tr>
<td>
<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\">
<tr>
<td colspan=\"3\">
There are an error has occured during executing your submission!!!!
");
if(empty($title)) { echo"<li>The <b>Title</b> still blank !!!!</li>"; }
if(empty($penulis)) { echo"<li><b>Your Name</b> still blank !!!!</li>"; }
if(empty($content)) { echo"<li><b>Content</b> still blank !!!!</li>"; }
echo("
</td>
</tr>
</table>
<tr>
<td>
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<form method=\"post\" action=\"gbinput.php\">
<tr>
<td align=\"center\" colspan=\"3\" bgcolor=\"#93CDF5\">
<span class=\"teks10_normal\"><span class=\"style1\">Give Your Post or Comment</span></span></td>
</tr>
<tr>
<td align=\"center\" colspan=\"3\"> </td>
</tr>
<tr>
<td><span class=\"teks10_normal\"><span class=\"style1\">Title</span></span></td>
<td><div align=\"center\"><span class=\"teks10_normal\"><span class=\"style1\">:</span></span></div></td>
<td><input type=\"text\" name=\"title\" size=\"48\"></td>
</tr>
<tr>
<td><span class=\"teks10_normal\"><span class=\"style1\">Your Name</span></span></td>
<td><div align=\"center\"><span class=\"teks10_normal\"><span class=\"style1\">:</span></span></div></td>
<td><input type=\"text\" name=\"penulis\" size=\"48\"></td>
</tr>
<tr>
<td><span class=\"teks10_normal\"><span class=\"style1\">Content</span></span></td>
<td><div align=\"center\"><span class=\"teks10_normal\"><span class=\"style1\">:</span></span></div></td>
<td rowspan=\"4\"><textarea rows=\"4\" name=\"content\" cols=\"36\"></textarea>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan=\"3\" align=\"center\"><br>
<input type=\"submit\" value=\"Submit\" name=\"submit\">
<input type=\"reset\" value=\"Clear\" name=\"Clear\">
</td>
</tr>
</form>
</table>
</td>
</tr>
</td>
</tr>
</table>
<br>
<br>
</body>
</html>
");
}
?>