Azeem Hassni
08-14-2012, 06:16 PM
hello guys !
how are you all !
i am facing a problum from las 20 mints .
i have created a form to insert data into the database !
when i filled the form and pressed Submit !
that says " Your post has been added ! "
but i gone to phpmyadmin to see the Data .
so no data was there .
so my queston is that why the form not inserting data in database ?
plz any one can help me .
this is the Code
echo "<h3> Post Comment to Guestbook </h3>";
if ($_POST['postbtn']){
$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$message = strip_tags($_POST['message']);
if ($name && $email && $message){
$time = date("h:i A");
$date = date("F d, Y");
$ip = $_SERVER['REMOTE_ADDR'];
##########################################################
# Here We are Geting the form data to insert in database #
##########################################################
mysql_query("INSERT INTO gb (name, email, message, time, date, ip,) VALUES (
'$name', '$email', '$message', '$time', '$date', '$ip',)");
echo "Your Posted has been added ! ";
}
else
echo "All fields are required !";
}
echo "<form method='POST' action='./gb.php'>
<table>
<tr>
<td>Name:</td>
<td><input type='text' name='name' style='width: 200px;' /></td>
</tr>
<tr>
<td>Email:</td>
<td><input type='text' name='email' style='width: 200px;' /></td>
</tr>
<tr>
<td>Message:</td>
<td><textarea name='message' style='width: 200px; height: 100px;'> </textarea></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='postbtn' value='submit' /></td>
</tr>
</table>
";
sorry for my english .
and thanks in Advance !
how are you all !
i am facing a problum from las 20 mints .
i have created a form to insert data into the database !
when i filled the form and pressed Submit !
that says " Your post has been added ! "
but i gone to phpmyadmin to see the Data .
so no data was there .
so my queston is that why the form not inserting data in database ?
plz any one can help me .
this is the Code
echo "<h3> Post Comment to Guestbook </h3>";
if ($_POST['postbtn']){
$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$message = strip_tags($_POST['message']);
if ($name && $email && $message){
$time = date("h:i A");
$date = date("F d, Y");
$ip = $_SERVER['REMOTE_ADDR'];
##########################################################
# Here We are Geting the form data to insert in database #
##########################################################
mysql_query("INSERT INTO gb (name, email, message, time, date, ip,) VALUES (
'$name', '$email', '$message', '$time', '$date', '$ip',)");
echo "Your Posted has been added ! ";
}
else
echo "All fields are required !";
}
echo "<form method='POST' action='./gb.php'>
<table>
<tr>
<td>Name:</td>
<td><input type='text' name='name' style='width: 200px;' /></td>
</tr>
<tr>
<td>Email:</td>
<td><input type='text' name='email' style='width: 200px;' /></td>
</tr>
<tr>
<td>Message:</td>
<td><textarea name='message' style='width: 200px; height: 100px;'> </textarea></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='postbtn' value='submit' /></td>
</tr>
</table>
";
sorry for my english .
and thanks in Advance !