Dear all;
I write a HTML form that ask user to post an announcement, the subject and body must be inserted into DB. But the problem that I face is the data is not inserted.
Any body can help me please to tell me what is the error.
Thanks.
Here are my code.[php]<?php
$host = "localhost" ;
$user = "";
$password = "";
$db = "e-school";
$table = "announceme nt";
mysql_connect($ host,$user,$pas sword) or die("The connection the the specified DataBase is failed. Please try again!");
mysql_select_db ($db);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Language" content="ar-sa">
<title>POSTIN G ANNOUNCEMENT</title>
</head>
<body>
<?php
if (isset("submit" )) {
$subject = $_POST['subject'];
$body = $_POST['body'];
$date = "20/4/2008";
$sql = "INSERT INTO $table VALUES('$subjec t', '$body', '$date')";
if (!mysql_query($ sql)) {
die('ERROR..');
}else{
echo "Successful l... ";
}
mysql_close($co n);
}else{
?>
<form action="" method="POST" >
<dl>
<dd>
<p dir="rtl"><b><s pan lang="ar-ae"><font size="4" color="#800000" >
Subject </font></span></b></dd>
<dd>
<p dir="rtl"><font size="4" color="#800000" >
<input size="54" maxlength="256" name="subject" style="font-size: 12pt; font-family: Times New Roman"></font></dd>
</dl>
<p dir="rtl"><b><s pan lang="ar-ae"><font size="4" color="#800000" >Body:</font></span></b></p>
<dl>
<dd>
<p dir="rtl"><font size="4" face="Times New Roman" color="#0000FF" >
<textarea name="body" rows="10" cols="57" style="font-size: 12pt; font-family: Times New Roman" dir="rtl"></textarea></font></dd>
</dl>
<p dir="rtl"><font color="#800000" size="4">
<input type="submit" value="Submit" name="submit" style="font-size: 12pt"></font><b><font size="4" color="#800000" >
</font></b><font size="3" color="#800000" >
<input type="reset" value="Reset" name="clear" style="font-size: 12pt"></font></p>
</form>
<?php
}
?>
</body>
</html>[/php]
I write a HTML form that ask user to post an announcement, the subject and body must be inserted into DB. But the problem that I face is the data is not inserted.
Any body can help me please to tell me what is the error.
Thanks.
Here are my code.[php]<?php
$host = "localhost" ;
$user = "";
$password = "";
$db = "e-school";
$table = "announceme nt";
mysql_connect($ host,$user,$pas sword) or die("The connection the the specified DataBase is failed. Please try again!");
mysql_select_db ($db);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Language" content="ar-sa">
<title>POSTIN G ANNOUNCEMENT</title>
</head>
<body>
<?php
if (isset("submit" )) {
$subject = $_POST['subject'];
$body = $_POST['body'];
$date = "20/4/2008";
$sql = "INSERT INTO $table VALUES('$subjec t', '$body', '$date')";
if (!mysql_query($ sql)) {
die('ERROR..');
}else{
echo "Successful l... ";
}
mysql_close($co n);
}else{
?>
<form action="" method="POST" >
<dl>
<dd>
<p dir="rtl"><b><s pan lang="ar-ae"><font size="4" color="#800000" >
Subject </font></span></b></dd>
<dd>
<p dir="rtl"><font size="4" color="#800000" >
<input size="54" maxlength="256" name="subject" style="font-size: 12pt; font-family: Times New Roman"></font></dd>
</dl>
<p dir="rtl"><b><s pan lang="ar-ae"><font size="4" color="#800000" >Body:</font></span></b></p>
<dl>
<dd>
<p dir="rtl"><font size="4" face="Times New Roman" color="#0000FF" >
<textarea name="body" rows="10" cols="57" style="font-size: 12pt; font-family: Times New Roman" dir="rtl"></textarea></font></dd>
</dl>
<p dir="rtl"><font color="#800000" size="4">
<input type="submit" value="Submit" name="submit" style="font-size: 12pt"></font><b><font size="4" color="#800000" >
</font></b><font size="3" color="#800000" >
<input type="reset" value="Reset" name="clear" style="font-size: 12pt"></font></p>
</form>
<?php
}
?>
</body>
</html>[/php]
Comment