I'll be sure to post up some download codes here if I get it going...
Thanks again.
finny
Moderator: General Moderators
Code: Select all
<?php
/* Connect to the Database */
$host="localhost";
$user="username";
$password="password";
$database = "db_name";
$connection = mysql_connect($host,$user,$password)
or die ("Couldnt connect to server.");
$db = mysql_select_db("$database", $connection)
or die ("Could not connect to database");
/* Pass form input to variable */
$userEntry = $_postCode: Select all
;
/* See if code exists in Database and pass it to variable $code */
$findCode = "SELECT code from Download
WHERE code='$userEntry'";
$code = mysql_query($findCode)
or die ("Could not execute query.");
/* If Code is 'blank' echo invalid code, else, get the row and check if used = n */
if ($code == "")
{
echo "You have entered an invalid Code. Please click 'Back' to try again.";
}
else
{
$getRow = mysql_fetch_array($code,mysql_assoc);
if ( $getRow['used'] == "n" )
{ echo "Append 'location' to current dir and start download";
$yesNo = "UPDATE download SET used=y WHERE code='$userEntry'";
$used = mysql_query($yesNo)
or die ("Couldnt execute Yes/No query"); }
else
{ echo "This code has already been used. If you have received this message in error please contact info@email.com for help.";}
}
?>Code: Select all
Warning: mysql_fetch_array(): The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH. in /home/webfolder/public_html/download_folder/download.php on line 35
This code has already been used. If you have received this message in error please contact info@email.com for help.Code: Select all
This code has already been used. If you have received this message in error please contact info@email.com for help.Code: Select all
<?php
/* Connect to the Database */
$host="localhost";
$user="db_user";
$password="password";
$database = "db_name";
$connection = mysql_connect($host,$user,$password)
or die ("Couldnt connect to server.");
$db = mysql_select_db("$database", $connection)
or die ("Could not connect to database");
/* Pass form input to variable */
$userEntry = $_postCode: Select all
;
/* See if code exists in Database and pass it to variable $code */
$findCode = "SELECT code from Download
WHERE code='$userEntry'";
$code = mysql_query($findCode)
or die ("Could not execute query.");
/* If Code is 'blank' echo invalid code, else, get the row and check if used = n */
if ($code == "")
{
echo "You have entered an invalid Code. Please click 'Back' to try again.";
}
else
{
$getRow = mysql_fetch_array($code,MYSQL_ASSOC);
if ( $getRow['used'] == "n" )
{ echo "Append 'location' to current dir and start download";
$yesNo = "UPDATE Download SET used='y' WHERE code='$userEntry'";
$used = mysql_query($yesNo)
or die ("Couldnt execute Yes/No query");
}
else
{ echo "This code has already been used. If you have received this message in error please contact info@email.com for help.";
}
}
?>Code: Select all
; " with "$userEntry = $_post[[color=red]'[/color]code[color=red]'[/color]];"Code: Select all
<?php
//...
/* See if code exists in Database and pass it to variable $code */
$findCode = "SELECT `used`, `code` from Download WHERE `code`='$userEntry'";
$code = mysql_query($findCode) or die ("Could not execute query.");
/* If Code is 'blank' echo invalid code, else, get the row and check if used = n */
if (!$code)
{
echo "You have entered an invalid Code. Please click 'Back' to try again.";
}
else
{
$getRow = mysql_fetch_array($code,MYSQL_ASSOC);
if ( $getRow['used'] == "n" )
{
echo "Append 'location' to current dir and start download";
$yesNo = "UPDATE Download SET `used`='y' WHERE `code`='$userEntry'";
$used = mysql_query($yesNo) or die ("Couldnt execute Yes/No query");
}
else
{ echo "This code has already been used. If you have received this message in error please contact info@email.com for help.";
}
}