Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
I have a form that I want verify if an email address is in my database and then if it is download a file. The part that checks the database works but I can't get the remainder of the code to work. Please help. I can get each part to work seperatly but not together.Code: Select all
<form id="download_form" name="download_form" method="get">
<table width="395" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="215"><input name="email" type="text" id="email"></td>
<td width="169"><em>:Email Address</em></td>
</tr>
<tr><td colspan="2"><select name="file_name" id="file_name">
<option value="jca">Java Calendar jar</option>
<option value="bmi">Body Mass Index jar</option>
<option value="calendar">Calendar jar</option>
<option value="mailtest">Mail Test jar</option>
<option value="sendmail">Send Mail jar</option>
<option value="pwdgen">Password Generator jar</option>
<option value="textscroller">Text Scroller jar</option>
<option value="viewsource">View WebPage Source jar</option>
<option value="htmlcalendar">HTML Calendar Generator Application</option>
<option value="passwordassistant">Password Assistant 2.0</option>
</select></td></tr>
<tr>
<td colspan="2"><input type="Submit" value="Download"></td>
</tr>
<?php
// donwload file from database
function getFile($file)
{
echo "<tr><td>$file . in the function</td></tr>";
$query = "Select item_number, jar_file, jar_name FROM jars WHERE jar_name ='$file'";
$result = mysql_query($query) or die('Error, query failed');
list($item_number, $jar_file, $jar_name) = mysql_fetch_array($result);
header("Content-length: $item_number");
header("Content-type: $jar_file");
header("Content-Disposition: attachment; filename=$jar_name");
}
if(isset($_GET['file_name']))
{
//openning the database
include 'php\opendb1.php';
//assigning variables
$e_id = $_GET['email'];
$f_id = $_GET['file_name'];
//checking to see if the email address is already in the database if not it will be added to the database
$email_query = "SELECT email_address, date FROM email WHERE email_address = '$e_id'";
$e_result = mysql_query($email_query) or die ('Error, query failed');
//get number of rows returned in the result set
$num=mysql_numrows($e_result);
echo "<tr><td>$f_id</td></tr>";
//if no email address is returned then email address will be added to the database
if($num == 0)
{
$now = date("Ymd");
$insert_query = "INSERT INTO email VALUES ('$e_id','$now')";
mysql_query($insert_query) or die('Error, insert query failed');
echo "<tr><td><font color='white'><em>email address added to database</em></font></td></tr>";
}
else
{
$i=0;
while ($i < $num)
{
$my_results = mysql_result($e_result,$i,"email_address");
echo "<tr><td><font color='white'><em>'$my_results' already in our database</em></font></td></tr>";
$i++;
}
}
getFile($f_id);
include 'php/closedb.php';
exit;
}
?>
</table>
</form>feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]