dongmu3187 2013-09-07 13:19 采纳率: 0%
浏览 22

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

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

  • 写回答

3条回答 默认 最新

  • duanhai4046 2013-09-07 13:22
    关注

    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'];
        }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM