0

i am working on a article(product) based site where i want users to make comments...

i am taking product id from product url... and inserting comment through insert query but don't know why it fails... any help??? i echo the query and its showing data

 <form action="" method="post">
<label style="color: red; font-size: 17px;">Commenter *</label><br>
<input type="text" name="c_name" style="margin-left: 0px; width:    200px;     border: 1px groove black;" required="required" placeholder="   Specify your name"/><br>
<br>

 <label style="color: red; font-size: 17px">Comment *</label><br>
<textarea  style="margin-left: 0px; width: 400px; height: 200px;   border:  1px groove black;"required="required" name="c_msg"></textarea><br>
<input style="float: right; margin-right: 280px; width: 80px; background- color: #e99067; color: white; font-family: serif;" type="submit"  name="commentit" value="Publish">

  include('includes/connect.php');
  if(isset($_GET['pro_id'])){
   $product_id=$_GET['pro_id'];

  if(isset($_POST['commentit'])){


     $c_name=$_POST['c_name'];
    $c_msg=$_POST['c_msg'];

   $add_c="insert into comments      
 (product_id,comment_name,comment_date,comment_msg)
            values ('$c_name',Date(),'$c_msg','$product_id')";

    $run_c=mysqli_query($con, $add_c);

        if($run_c){

                            echo "<script>alert('Comment Published   


Successfully')</script>";
                                echo  
     "<script>window.open('index.php','_self')</script>";
                        }
                        else {
                            echo "nothing done";
                        }
Matt
  • 14,906
  • 27
  • 99
  • 149
  • 1
    you know it's failing because ...? see also: http://docs.php.net/manual/en/mysqli.error.php and http://docs.php.net/security.database.sql-injection – VolkerK Nov 01 '15 at 11:27
  • Do you really want to insert `date` to `comment_name` field? – u_mulder Nov 01 '15 at 11:40
  • Please Im having the same problem here is my post. http://stackoverflow.com/questions/33590352/how-to-insert-current-id-of-game-in-database – David Nov 08 '15 at 04:16

0 Answers0