<?php include("include/connection.php"); session_start(); $ses_id = session_id(); $ID = (int)$_REQUEST['id']; ?> PHP: <?php $productdetail = mysql_query("select * from productdetail where PID = '$ID'" , $con); while($query_data = mysql_fetch_array($productdetail)) { $ID = $query_data['PID']; $PCode = $query_data['PCode']; $PName = $query_data['PName']; $PPrice = $query_data['PPrice']; $Stock = $query_data['StockA']; $PDescription = $query_data['ProductDescription']; $Thumbnail = $query_data['Thumbnail']; $Picture1 = $query_data['Picture1']; $Picture2 = $query_data['Picture2']; $Picture3 = $query_data['Picture3']; $Picture4 = $query_data['Picture4']; } ?> PHP: when I click on submit nothing happens
There were loads of issues with your script and I've moved some things around to give you some ideas. Your key problem, though, was that the submit button didn't have a name and therefore wasn't in the $_POST array. The variable names in the form didn't match the script either, and you aren't saving the id of the item being reviewed so the review. <?php if (isset($_POST['submit'])) { // connect to database!!! //echo "heloo"; $id = intval($_POST['id']); if ($id > 0) { $Rname = mysql_real_escape_string(stripslashes(htmlentities($_POST["txtname"]))); $Reviewbtn = $_POST["reviewbtn"]; $Txtbox = mysql_real_escape_string(stripslashes(htmlentities($_POST["txtbx"]))); //$id needs to be saved into the database $sql = "INSERT INTO `reviews` (`Name`, `Comments`, `Rating`) VALUES('{$Rname}','{$Reviewbtn}','{$Txtbox}')"; var_dump($sql); $sql = mysql_query($sql, $con) or die(mysql_error() . '<br/>' . $sql); mysql_close($con); header("location: product_detail.php?result=ok"); exit; } else header("location: product_detail.php?result=fail"); } if (isset($_GET['result'])) { echo "<div id='feedback span5'>"; if ($_GET['result'] == 'ok') echo "Record added succesfully."; else echo "Failed to add"; echo "</div>"; } ?> <div class="span5"> <div class="span2"> <address> <h4 class="label-info"><span>Product Detail</span></h4> <strong>Product Name:</strong> <span><?php echo $PName; ?></span><br> <strong>Product Code:</strong> <span><?php echo $PCode; ?></span><br> <strong>Product Price:</strong> <span><?php echo $PPrice; ?></span><br> <strong>Availability in Stock:</strong><span style="color:#FF0000;"> <?php if ($Stock == 1) { echo '<strong>Available</strong>'; } else { echo "Not Available"; } ?> </span><br> </address> </div> <div class="span3 col"> <div class="block"> <h4>Product Description</h4> <span class="uneditable-textarea"><?php echo $PDescription; ?></span> </div> </div> </div> <div class="row"> <div class="span9"> <div class="span6 "> <h4>Review(0)</h4> <p>There are no review for this product</p> <h4>Write a Review</h4> <form id="Re" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?> "> <p>Your Name:</p> <input type="text" id="txtname" name="Rname" placeholder="write your name..." /> <p>Your Review</p> <label>Excellent <input type="radio" name="reviewbtn" class="radio" value="Excelent" /></label> <label>Good <input type="radio" class="radio" name="reviewbtn" value="Good" /></label> <label>Poor <input type="radio" class="radio" name="reviewbtn" value="Poor" /></label><br/> <textarea id="txtreview" name="txtbx" cols="50" rows="10" class="container-fluid"></textarea> <input type='hidden' name='id' value="<?php echo $ID; ?>"><br/> <input type="submit" value="submit" name="submit" class="btn" /> </div> </div> </div> </div> PHP: