早上好,我是香港人,希望我的英语没问题..
我的问题是...
我无法将 $_GET 方法保存到数据库,但没有错误。它在数据库中有一条空记录..
<form method="get" action="customizeText.php">
<?php
$customizeName = '1set';
$customizePrice = $_GET["p"];
$customizeColor1 = $_GET["c1"];
$customizeColor2 = $_GET["c2"];
$customizeColor3 = $_GET["c3"];
$customizeText1 = 'I';
$customizeText2 = 'L';
$customizeText3 = 'U';
$customizePackage = 'red';
$quantity = 1;
?>
<div><strong><?php echo $customizeName; ?></strong></div>
<div class="product-price"><?php echo "$".$customizePrice; ?></div>
<?php echo $customizeColor1; ?>
<?php echo $customizeColor2; ?>
<?php echo $customizeColor3;?>
<div>
<input type="submit" value="Add to cart" class="btnAddAction" name="btnAddAction" /></div>
</form>
<?php
if (isset($_GET['btnAddAction'])) {
$sql= "INSERT INTO customizeproduct (custProName, custProPrice, custProColor1, custProColor2, custProColor3, custProText1, custProText2, custProText3, custProPackage) VALUES ('$customizeName', '$p', '$customizeColor1', '$customizeColor2', '$customizeColor3', '$customizeText1', '$customizeText2', '$customizeText3', '$customizePackage')";
if (mysqli_query($connect, $sql)){
echo "SAVE IN DB";
}else{
echo "NO WAY";
}
另外,我尝试回显 $customizeColor1, 2, 3 ,它可以显示数据。 所以,我不知道为什么我无法将数据保存在数据库中。
有人可以帮助我吗?
最佳答案
您将表单方法设置为 POST
并在 GET
中访问表单值。
您需要将表单方法设置为 GET
或使用 POST
关于php - 将 $_GET 方法保存到数据库中并更改它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36262562/