Hello,
I cant seem to figure out why this code is not writing to the database? It is a file that is included in another file that already has a connection to the database established. It does not seem like it is running at all but there are no errors being returned. It is suppose to be generating a download key and inserting it into the database then sending an email with the download link provided in it. Can anyone help me figure out why its not inserting anything into the database or sending out emails? Here is the code:
[code=php]
<?php
$keys = htmlspecialchars($numbkey1, ENT_QUOTES);
$successkeys = 0;
?>
<?php if(is_numeric($keys) && $filename != “”) {
// A script to generate unique download keys for the purpose of protecting downloadable goods
if(empty($_SERVER[‘REQUEST_URI’])) {
$_SERVER[‘REQUEST_URI’] = $_SERVER[‘SCRIPT_NAME’];
}
// Strip off query string so dirname() doesn’t get confused
$url = preg_replace(‘/?.*$/’, ”, $_SERVER[‘REQUEST_URI’]);
$folderpath = ‘http://’.$_SERVER[‘HTTP_HOST’].’/’.ltrim(dirname($url), ‘/’).’/’;
// Get the activation time
$time = date(‘U’);
for ($counter = 1; $counter <= $keys; $counter += 1) {
// Generate the unique download key
$key = substr(uniqid(md5(rand())), 0, 12);
// Generate the link
$link=$folderpath . “download.php?id=” . $key . “<br />n”;
// Sanitize the query
$query = “INSERT INTO downloadkeys (uniqueid,timestamp,lifetime,maxdownloads,downloads,filename) VALUES(“$key”,”$time”,’%d’,’%d’,’%d’,’%s’)”,
$lifetime,
$maxdownloads,
0,
mysqli_real_escape_string($filename, $dbc),
// Write the key and other information to the DB as a new row
$registerid = mysqli_query($query) or die(mysqli_error());
$successkeys++;
}
}
if ( isset($_POST[‘payment_status’])
&& ($_POST[‘payment_status’] == ‘Completed’)
&& ($_POST[‘receiver_email’] == ‘[email protected]’)
&& ($_POST[‘mc_gross’] == 9.99)
&& ($_POST[‘mc_currency’] == ‘USD’)
&& (!empty($_POST[‘txn_id’]))
) {
$numbkey1 = 1;
$filename = ‘cover01.zip’;
$lifetime = 31556926;
$maxdownloads = 2;
} elseif {
( isset($_POST[‘payment_status’])
&& ($_POST[‘payment_status’] == ‘Completed’)
&& ($_POST[‘receiver_email’] == ‘[email protected]’)
&& ($_POST[‘mc_gross’] == 14.99)
&& ($_POST[‘mc_currency’] == ‘USD’)
&& (!empty($_POST[‘txn_id’]))
) {
$numbkey1 = 1;
$filename = ‘cover02.zip’;
$lifetime = 31556926;
$maxdownloads = 2;
} else { // Problem finding the order!
trigger_error(‘The transaction could not be found in the table!’);
}
}
}
}
}
if($successkeys > 0) {
$body = “Thank you for purchasing our E-Book. Here is your custom download link:” $link.;
mail($_POST[’email’], ‘Strategies for Stretching Your Income Delivery’, $body, ‘From: [email protected]’);
}
Thanks in advance if you can help me figure this out.