Saturday, 7 September 2013

form submission on product detail page

form submission on product detail page

I have following code on the top of product detail page
<?php
include("include/connection.php");
session_start();
$ses_id = session_id();
$ID = (int)$_REQUEST['id'];
?>
<?php
if (!isset ($_POST['submit']))
{
?>
<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 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>
Excelent<input type="radio" name="reviewbtn"
class="radio" value="Excelent" />
Good<input type="radio" class="radio"
name="reviewbtn" value="Good" />
Poor<input type="radio" class="radio"
name="reviewbtn" value="Poor" /><br/>
<textarea id="txtreview" name="txtbx"
cols="50" rows="10"
class="container-fluid"></textarea>
<input type="submit" value="submit"
class="btn" />
</div>
</div>
</div>
</div>
<?php
}
else
{
$Rname = mysql_real_escape_string( stripslashes(
htmlentities($_POST["Rname"])));
$Reviewbtn = $_POST["reviewbtn"];
$Txtbox= mysql_real_escape_string( stripslashes(
htmlentities($_POST["txtbx"])));
$sql=mysql_query ("INSERT INTO reviews (Name, Comments,Rating)
VALUES('$Rname','$Reviewbtn','$Txtbox')", $con) or die
(mysql_error());
echo "Record added succesfully. You will be redirected to previous
page in 5 seconds";
header( "refresh:5;url= product_detail.php" );
}
mysql_close($con);
?>
here I am getting error Notice: Undefined index: id in \product_detail.php
on line 5 ( which is $ID = (int)$_REQUEST['id']; )
basically I am building a rating form on a product,please if someone can
modify the code so form submission could be done using ajax jquery call so
page should not load again

No comments:

Post a Comment