简体   繁体   中英

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

<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. Since you are inserting data into a database, POST is correct, so replace $_GET with $_POST .

You are also looking for Confirm when your button is named confirm . PHP is case sensitive, so replace that too.

$_POST['confirm']

You also appear to be at risk of SQL injection .

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'] .

Your form is sending POSTdata, not GET. Either change the form's method, or check for $_POST['confirm'] .

You have set the method to be post. Try with $_POST['Confirm'];

In both your GET string, and your form (which uses POST ), the field is "confirm" , not "Confirm" . Note the lower case 'c' .

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

you are using php variable in html may be that's the issue replace this;

<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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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