i'm trying to insert data into database using php and mysql but my query isn't running. i have to insert data into comments table using php and mysql here is my code. if there is any errors please tell me.
<pre>if(isset($_POST['submit-comment']))
{
$cs_name = $_POST['full-name'];
$cs_email = $_POST['email'];
$cs_website = $_POST['website'];
$cs_comment = $_POST['comment'];
$cs_date = time();
if(empty($cs_name) or empty($cs_email) or empty($cs_comment))
{
echo "<script type='text/javascript'>swal({ title: 'Opps!', text: 'You Have To Fill All (*) Fields!', imageUrl: 'images/info.png' });</script>";
}
else
{
$cs_query = "INSERT INTO `comments`(`id`, `date`, `name`, `username`, `post_id`, `email`, `website`, `image`, `comment`, `status`) VALUES (NULL,$cs_date,$cs_name,user,$post_id,$cs_email,$cs_website,NULL,$cs_comment,pending)";
$cs_run = mysql_query($cs_query);
if($cs_run)
{
echo "<script type='text/javascript>setTimeout(function () { swal('Good job!', 'Your Commnet Has Been Submited Waiting For Approvel!', 'success')}, 100);</script>";
}
else
{
echo "<script type='text/javascript'>swal({ title: 'Opps!', text: 'Your Commnet Not has Been Submited!', imageUrl: 'images/delete.png' });</script>";
}
}
}
?>
What I have tried:
i have tried but not get the answer i want.