简体   繁体   English

if(isset($_GET['Confirm'])) 我做错了什么?

[英]What am I doing wrong here if(isset($_GET['Confirm']))?

My Get confirm isn't triggering the query?我的获取确认没有触发查询? Can anyone see what I'm doing wrong?谁能看到我做错了什么?

url: http://www.example.co.uk/registerinterest.php?productid=125&confirm=Confirm url: http://www.example.co.uk/registerinterest.php?productid=125&confirm=Confirm

<div class="confirminterest">
     <form action="registerinterest.php?productid=' . $productid . '" method="post" enctype="multipart/form-data">
       <input name="confirm" type="submit" id="confirm" value="Confirm" />
     <input name="cancel" type="button" id="cancel" value="Cancel" /></form>
   </div>

 if (isset($_GET['Confirm'])) {
         $addinterest = mysql_query("INSERT INTO tm_credits_spent (fk_customer_id, fk_product_id, int_credits_spent) VALUES('$pid','$productid','$adminfee')") or die (mysql_error());
}

You are looking for GET data when your form uses the POST method.当您的表单使用 POST 方法时,您正在寻找 GET 数据。 Since you are inserting data into a database, POST is correct, so replace $_GET with $_POST .由于您要将数据插入数据库,因此 POST 是正确的,因此将$_GET替换为$_POST

You are also looking for Confirm when your button is named confirm .当您的按钮名为confirm时,您也在寻找Confirm PHP is case sensitive, so replace that too. PHP 区分大小写,因此也将其替换。

$_POST['confirm']

You also appear to be at risk of SQL injection .您似乎也面临SQL 注射的风险。

Adding my own answer as the others are missing that the name of your input is "confirm", not "Confirm" (that's its value).添加我自己的答案,因为其他人缺少您输入的名称是“确认”,而不是“确认”(这是它的价值)。

So you must check isset() for $_POST['confirm'] , not $_POST['Confirm'] or $_GET['confirm'] .因此,您必须检查isset()$_POST['confirm'] ,而不是$_POST['Confirm']$_GET['confirm']

Your form is sending POSTdata, not GET.您的表单正在发送 POST 数据,而不是 GET。 Either change the form's method, or check for $_POST['confirm'] .要么更改表单的方法,要么检查$_POST['confirm']

You have set the method to be post.您已将方法设置为发布。 Try with $_POST['Confirm'];试试 $_POST['Confirm'];

In both your GET string, and your form (which uses POST ), the field is "confirm" , not "Confirm" .在您的GET字符串和您的表单(使用POST )中,该字段是"confirm" ,而不是"Confirm" Note the lower case 'c' .注意小写字母'c'

Try: if (isset($_GET['confirm'])) { (or if (isset($_POST['confirm'])) { ).尝试: if (isset($_GET['confirm'])) { (或if (isset($_POST['confirm'])) { )。

you are using php variable in html may be that's the issue replace this;您在 html 中使用 php 变量可能就是这个问题,请替换它;

<form action="registerinterest.php?productid=' . $productid . '" method="post" enctype="multipart/form-data">

with

<form action="registerinterest.php?productid=' .<?php $productid ?>. '" method="post" enctype="multipart/form-data">

and yes use $_POST['confirm'] for condition.是的,使用$_POST['confirm']作为条件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM