【发布时间】:2015-08-20 04:25:37
【问题描述】:
我在这里遇到了问题,我正在自己的大学网站上工作,但是我遇到了一个问题,我在任何地方都找不到答案。我有一个产品页面和一个 php 模块来处理将项目添加到购物车会话数据,但是我收到了这个错误:
https://saturn.csit.rmit.edu.au/~s3482230/wp/a2/product.php?productid=P001' 是通过安全连接加载的,但包含一个针对不安全端点“模块:添加到 cart.php”的表单。该端点应通过安全连接提供。 (该网站托管在学校服务器上,您无需登录就无法访问,因此您无法查看它。
但是表格是这样写的……
<form class=productqty action="module: add to cart.php" method="post">
<p id=price>$<span id=pricedouble>0</span></p>
<input name="price" id=prodprice type="hidden" value="20.00" required/>
<input name="product code" type="hidden" value="P001" required/>
<input name="quantity" id=qtyinput maxlength="3" type="text" value="1"
onblur='checkButtons()' onkeypress='checkIfNumber(event)' required/>
<button id=negativebutton type="button" onclick="minusOne()" disabled> - </button>
<button id=positivebutton type="button" onclick="plusOne()"> + </button>
<input type="submit" value="Purchase" />
</form>
处理添加到会话和购物车的模块代码是:(未完成)
<?php
session_start();
if (isset($_SESSION['user'])) {
}
$_SESSION['cart'][$_POST['product code']]['qty'] = $_POST['quantity'];
$_SESSION['cart'][$_POST['product code']]['price'] = $_POST['price'];
header("Location: ".$_SESSION["redirect_url"]);
?>
注意:redirect_url 用于在登录和注销后重定向并在这些模块上工作,因此它应该在这里工作,还尝试将重定向注释掉但不会更改警告,我希望这是足够的信息。
【问题讨论】:
-
module: add to cart.php不是有效的网址...您必须将网址放入购物车脚本(指定 https: 协议)。 -
它位于同一目录中,并且我在服务器上有一个 .htaccess 文件类型,因此它可以工作并将任何 HTTP 站点重定向为 HTTPS。我已经为我的 'login' 和 'logout' .php 模块做了这个并且工作正常。
-
module 不是有效的 url 方案.. 表单中的 action 属性必须是有效的 url.... 如果
add_to_cart.php与product.php位于同一目录中,则删除 " module: " 只需要表单操作中的文本。 -
名称是 'module: add to cart.php' 这只是我命名文件以了解文件是什么的方式。
-
我会重命名文件以删除冒号和空格...通常的约定是在该位置使用连字符...即
module-add-to-cart.php
标签: php forms security https module