i have this script that works very well. Basically it allows the user to attach a scanned pdf file of shipping forms and attach to the form.
-
<?
-
include_once("format.php");
-
echo $format;
-
-
?>
-
</div>
-
-
<div id="main"> <a name="TemplateInfo"></a>
-
<h1>Add Shipment Tracking</h1>
-
-
<form method="post" enctype="multipart/form-data">
-
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
-
<tr>
-
<td width="246">
-
-
<b>Description:</b>
-
<tr>
-
<td>
-
<input type='textarea' name='description' value='' size='50%'>
-
<br />
-
-
-
<b>Send/Receive:</b>
-
<select name='send' value=''>
-
<option selected value=''>
-
<option>Sent
-
<option>Received
-
</select>
-
-
<b>Carrier:</b>
-
<select name='carrier' value=''>
-
<option selected value=''>
-
<option>UPS
-
<option>FEDEX
-
<option>DHL
-
<option>Sonic Air
-
<option>Other
-
</select><br /><br />
-
-
-
-
-
<tr>
-
<td colspan='1'>
-
<b>Tracking Numbers:</b><br />
-
<textarea name='tracking' rows='6' value='' wrap='hard'>
-
<? echo $_POST['tracking'];?>
-
</textarea>
-
</td></tr><br />
-
-
<b>Upload Document:</b><br />
-
<input type="hidden" name="MAX_FILE_SIZE" value="20000000">
-
<input name="userfile" type="file" id="userfile">
-
<td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
-
</td>
-
-
</table>
-
</form>
-
-
<?
-
include_once('sql_connect.php');
-
-
?>
-
-
<?
-
-
if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)
-
{
-
-
-
$description = $_POST['description'];
-
$tracking = $_POST['tracking'];
-
$carrier = $_POST['carrier'];
-
$send = $_POST['send'];
-
-
$fileName = $_FILES['userfile']['name'];
-
$tmpName = $_FILES['userfile']['tmp_name'];
-
$fileSize = $_FILES['userfile']['size'];
-
$fileType = $_FILES['userfile']['type'];
-
-
-
$fp = fopen($tmpName, 'r');
-
$content = fread($fp, filesize($tmpName));
-
$content = addslashes($content);
-
fclose($fp);
-
-
if(!get_magic_quotes_gpc())
-
{
-
$fileName = addslashes($fileName);
-
}
-
-
-
$query = "INSERT INTO ship_table (name, size, type, content1, description, tracking, carrier, send ) ".
-
"VALUES ('$fileName', '$fileSize', '$fileType', '$content1', '$description', '$tracking', '$carrier', '$send')";
-
-
mysql_query($query) or die('Error, query failed');
-
-
-
echo "<br>File $fileName uploaded<br>";
-
}
-
-
?>
-
Now here is the problem. How do I pull the file from the table from a search form. I have a simple little search form
-
-
<?
-
$content = $content. "
-
<form method='post' action='search_tracking_submit.php'>
-
<b>Track Shipment:</b> <br />
-
<input type='text' name='search'><br />
-
<input type='submit' name='submit_search' value='SEARCH!!'><br />
-
</form>";
-
-
echo "<div id='content'>"
-
.$content
-
."</div>";
-
-
-
?>
-
the end result looks like this
-
<?
-
include_once("./sql_connect.php");
-
-
-
-
-
-
$search = $_POST['search'];
-
$gettracking = "SELECT *
-
FROM ship_table
-
WHERE description LIKE '%$search%'
-
OR send LIKE '%$search%'
-
OR carrier LIKE '%$search%'
-
OR tracking LIKE '%$search%'
-
ORDER BY id ASC";
-
$gettrackingResult = mysql_query($gettracking);
-
-
while (list($id, $description, $send, $carrier, $tracking, $time_stamp) = mysql_fetch_row($gettrackingResult))
-
{
-
-
$content = $content.
-
"<b>ID #: </b>$id</a> <br />\n";
-
-
-
$content = $content.
-
"<b>Description: </b>$description</a> <br />\n";
-
-
$content = $content.
-
"<b>Status: </b>$send</a> <br />\n";
-
-
$content = $content.
-
"<b>Carrier: </b>$carrier</a> <br />\n";
-
-
$content = $content.
-
"<b>Tracking: <br /></b>$tracking</a> <br />\n";
-
-
$content = $content.
-
"<b>Time: </b>$time_stamp</a> <br /><br />\n";
-
-
-
}
-
-
echo "<div id='content'>"
-
.$content
-
."</div>";
-
?>
-
how do I add to content something like
File : file.name <---- this being a link to download the file