Hello,
I have a deadline approaching and I'm stuck. I have been working on creating a coupon code database for my client who will be offering the same promotion in several publications. They want to track the use of each UNIQUE code. I am now at a point where I'm stuck.
Here is what I have:
1) I created a database that has the 4 codes already inserted from a CSV file. The table has fields for coupon_id, coupon_code, and counter.
2) a page with a form for the customer to enter the promo code. (promo_code.html)
2) the promo_code.html page sends the contents to promo_verify.php (code below)
When I try to enter one of the codes, I just get a white page...which tells me something is not working, but at this point I do not know what's wrong. Any help would be greatly appreciated. Thanks!!
<?php
$promo = $_POST["promo"];
// verify if any stated fields has empty values
if(!isset($_POST['submit']))
{
//redirect to the form
print ($promo);
header("Location: /pages/error.html");
}
} elseif(empty($promo))
{
//they submitted the form without a code
}
else {
//there is a code, check to see it's valid...
// process the submission here
//update the counter field by 1
mysql_connect ("64.246.42.88", "retailersub", "subretailer");
mysql_select_db (retailers);
$sql = mysql_query("UPDATE promo_code SET counter = counter+1
WHERE coupon_code = $promo") or die (mysql_error());
header("Location: /pages/promo_code.html");
} else {
die (mysql_error());
}
}
?>
On another board, someone suggested the following, but I thought that was what I was doing....
if submit pressed
check the form fields
if ok
___check the promocode
_____if ok
________update it
________echo a message
___________exit the script
//u can then close the brackets or use else if to set appropriate messages
then the form goes here
Using PHP, how can I see if what they are submitting MATCHES what is already in the database and if it does, ad 1 to the counter of that coupon_id? ANY help would be GREATLY appreciated!!! Thank you, thank you!
Ryan