在产品详细信息页面上提交表单

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'];     

    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" />
            </form>
        </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

Use some other word as name attribute rather than naming it as id you can set it to user_id or something else you want,because it is not a good practice

if(isset($_REQUEST['user_id'])){
    $ID = $_REQUEST['user_id'];
    }

remove int from it there no need of it.

$ID = $_REQUEST['id'];

There is no Element named ID in your form

So when you are going to catch this it occurred error

 $ID = $_REQUEST['id']; 
                   ^ provide actual form element's name here 

When you coming to this page from previous page it is not showing error

after submitting from it is showing error.

If it is, add an hidden element into your form

<input type='hidden' name='id' value="<?php echo $ID; ?>">

It will solve the problem