gpt4 book ai didi

php - 产品详情页面上的表单提交

转载 作者:行者123 更新时间:2023-11-29 04:22:54 25 4
gpt4 key购买 nike

我在产品详细信息页面的顶部有以下代码

<?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);
?>

这里报错

Notice: Undefined index: id in \product_detail.php on line 5

(即 $ID = (int)$_REQUEST['id']; )

基本上我正在为产品构建评级表,如果有人可以修改代码以便可以使用 ajax jquery 调用完成表单提交,那么页面不应再次加载

最佳答案

从中删除不需要它的 int。

$ID = $_REQUEST['id'];

关于php - 产品详情页面上的表单提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18673705/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com