<input type="text" name="param" ...> means you need to use $submit = $_POST['param'];
pritaeas
Posting Expert
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
Hey, i updated the script. Still no changes to the database. I think there is something i am missing
What do you currently have?
evstevemd
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 462
Solved Threads: 392
Check line number 9 in coupon.php.
' ' . htmlspecialchars($_GET["coupon"]) . '';
What is this ? Perhaps, you should have.
$coupon = htmlspecialchars($_GET["coupon"]);
And then, if...else statement should go like below
if($coupon == ''){
echo "<h2>The request is invalid</h2>";
}
else{
$coupon_code = $coupon;
}
And the final one is, print_r in input field. Line 19 in coupon.php.
Replace above with:
<input type="text" name="couponcode" disabled value="<?php echo $coupon_code; ?>">
'<? ?>', may be the problem, you must enable to support this syntax in php.ini file.
Zero13
Practically a Master Poster
624 posts since Jan 2009
Reputation Points: 120
Solved Threads: 139
well, the code as i posted it works if i change this line:
to
$sql = " UPDATE coupons SET coupon_used= '0' WHERE coupon_code = 'abc2qsaa' ";
where abc2qsaa is one of the codes in my database.
I have made the changes you suggested as well, but the database still doesn't get updated.
this information is useful. Now, print the value of $submit and hence whole $sql and post result
evstevemd
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 462
Solved Threads: 392
Is not printing it. Maybe i am doing it wrong:
if(isset($_POST['usecode']))
{
$submit = $_POST['couponcode'];
$sql = " UPDATE coupons SET coupon_used= '0' WHERE coupon_code = '$submit' ";
print $submit;
}
do this
print_r($_POST);
echo "";
if(isset($_POST['usecode']))
{
$submit = $_POST['couponcode'];
$sql = " UPDATE coupons SET coupon_used= '0' WHERE coupon_code = '$submit' ";
echo $submit;
die()
}
evstevemd
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 462
Solved Threads: 392
Remove white space from this line.
$sql = " UPDATE coupons SET coupon_used= '0' WHERE coupon_code = '$submit' ";
Should be
$sql = "UPDATE `coupons` SET `coupon_used` = '0' WHERE `coupon_code` = '$submit'";
And print the above the query line, copy and past it into phpMyadmin and run it manually, and check how it works.
Zero13
Practically a Master Poster
624 posts since Jan 2009
Reputation Points: 120
Solved Threads: 139
Array ( [usecode] => Use Coupon )
As you posted above. $submit has wrong value stored. Check where $submit comes from.
Zero13
Practically a Master Poster
624 posts since Jan 2009
Reputation Points: 120
Solved Threads: 139