I am attempting to allow my members to upload an image along with a report and have the image show on an index page along with the data from the report.
I have a column in the table titled 'image' and it is set up as a BLOB NOT NULL.
The following is the FORM script:
<HTML>
<HEAD>
<BODY background="sky01.jpg">
<TITLE>PIREP INPUT FORM</TITLE>
<center><h2>AUTOMATED PIREP REPORTING FORM</h2></center>
<b>Please complete all information in the formats described next to the input boxes. Your data will be automatically added to your flight log and your totals updated.<P>
<?
$today = getdate();
$month = $today['mon'];
$day = $today['mday'];
$year=$today['year'];
?>
<form method="post" action="script.php">
DATE: <input type="text" name="date" value="<? echo $year?>-<? echo $month ?>-<? echo $day; ?>"><B>FORMAT='YYYY-MM-DD'</b><br>
NAME: <input type="text" name="name"><br>
MACID: <SELECT name="macid">
<OPTION SELECTED>---
<OPTION>MAC100
<OPTION>MAC101
<OPTION>MAC102
<OPTION>MAC103
<OPTION>MAC104
<OPTION>MAC496
<OPTION>MAC111
<OPTION>MAC116
<OPTION>MAC117
<OPTION>MAC127
<OPTION>MAC187
<OPTION>MAC188
<OPTION>MAC189
<OPTION>MAC190
<OPTION>MAC191
<OPTION>MAC192
<OPTION>MAC193
<OPTION>MAC194
<OPTION>MAC195
</select><br>
FLIGHT TIME: Enter as a decimal, rounded to one decimal place. <br>If you are flying a charter flight, please double your hours before entering the total here.<br>HOURS:<input type="text" name="hours"><br>
TYPE OF FLIGHT: <SELECT name="type">
<OPTION SELECTED>Macnet
<OPTION>Bushnet
<OPTION>Vatsim
<OPTION>Offline
<OPTION>Charter
<OPTION>Codeshare
<OPTION>Club Event
</select><BR>
DEPARTURE: <input type="text" name="departure"><b>USE ICAO CODE ONLY</b><br>
DESTINATION: <input type="text" name="destination"><b>USE ICAO CODE ONLY</b><br>
CHARTER #: <input type="text" name="charterno"><br>
CHARTER PAY: $<input type="text" name="charterdoll"><br>
COMMENT: <br><TEXTAREA name="comment" rows="10" cols="30"></TEXTAREA><br>
<form method="post" action="script.php" enctype="multipart/form-data">
SCREENSHOT:<input type="file" name="image"> <P>
If all information is correct, please click:
<input type="submit" name="submit" value="SUBMIT ">
</form>
</html>
SCRIPT.php looks like this:
<HTML>
<body background="sky01.jpg">
<a href="http://www.margaritaair.com/roster.html">BACK TO ROSTER</a><P>
</html>
<?php
$db = mysql_connect("localhost", "tddftegh","scarlet");
mysql_select_db("margaritaair_com",$db);
$date=$_POST['date'];
$name=$_POST['name'];
$macid=$_POST['macid'];
$hours=$_POST['hours'];
$type=$_POST['type'];
$departure=$_POST['departure'];
$destination=$_POST['destination'];
$charterno=$_POST['charterno'];
$charterdoll=$_POST['charterdoll'];
$comment=$_POST['comment'];
$image=$_POST['image'];
$sql = "INSERT INTO flightlog (date, name, macid, hours, type, departure, destination, charterno, charterdoll, comment, image) VALUES ('$date', '$name', '$macid','$hours','$type','$departure','$destination','$charterno','$charterdoll','$comment','$image')";
$result = mysql_query($sql);
if ($result) {
echo ("PIREP recorded successfully");
}
MySQL_close()
?>
<P>
</HTML>
And the index.php looks like this:
<html>
<head>
<body background="sky.jpg">
<a href="http://www.margaritaair.com/index.html">MAIN PAGE</a><P>
<A href="http://www.margaritaair.com/roster.html">ROSTER</a><P>
<a href="update.php">UPDATE / DELETE RECORD</a><br>
<?
include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
mysql_select_db ("margaritaair_com");
$query = "SELECT SUM(hours) AS total FROM flightlog WHERE macid='MAC100'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_assoc($result);
mysql_close();
?>
</html>
<?
include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM flightlog WHERE macid='MAC100' ORDER BY date DESC";
$result=mysql_query($query);
$num=mysql_numrows($result);
$date = date('j-m-y');
mysql_close();
echo "<b><h2><center>MAC100 FLIGHT LOG</h2></center></b><br>";
echo "<B><center>PILOT NAME: Todd Lucas<br></center>";
echo "<b><center>HOMETOWN: Lexington, SC<br></center>";
echo '<font size="+2">Total Hours Flown: '.$row['total'];
?>
<table border="2" cellspacing="2" cellpadding="2">
<tr>
<th><font face="Arial, Helvetica, sans-serif">ID</font></th>
<th><font face="Arial, Helvetica, sans-serif">MACID</font></th>
<th><font face="Arial, Helvetica, sans-serif">Name</font></th>
<th><font face="Arial, Helvetica, sans-serif">Date</font></th>
<th><font face="Arial, Helvetica, sans-serif">Type</font></th>
<th><font face="Arial, Helvetica, sans-serif">Departure</font></th>
<th><font face="Arial, Helvetica, sans-serif">Destination</font></th>
<th><font face="Arial, Helvetica, sans-serif">Time</font></th>
<th><font face="Arial, Helvetica, sans-serif">Charter #</font></th>
<th><font face="Arial, Helvetica, sans-serif">Charter Pay</font></th>
<th><font face="Arial, Helvetica, sans-serif">Comment</font></th>
<th><font face="Arial, Helvetica, sans-serif">Image</font></th>
</tr>
<?
$i=0;
while ($i < $num) {
$id=mysql_result($result,$i,"id");
$macid=mysql_result($result,$i,"macid");
$date=mysql_result($result,$i,"date");
$name=mysql_result($result,$i,"name");
$type=mysql_result($result,$i,"type");
$departure=mysql_result($result,$i,"departure");
$destination=mysql_result($result,$i,"destination");
$hours=mysql_result($result,$i,"hours");
$charterno=mysql_result($result,$i,"charterno");
$charterdoll=mysql_result($result,$i,"charterdoll");
$comment=mysql_result($result,$i,"comment");
$image=mysql_result($result,$i,"image");
$datePosted = "$date";
$formatted = date("M-d-Y", strtotime($datePosted));
$departure = strtoupper($departure);
$destination = strtoupper($destination);
?>
<tr>
<td><font face="Arial, Helvetica, sans-serif"><a href="update.php"><? echo "$id"; ?></a></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$macid"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$name"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? if (!$date) { echo " "; } else { echo $formatted; } ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? if (!$type) { echo " "; } else { echo $type; } ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? if (!$departure) { echo " "; } else { echo $departure; } ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? if (!$destination) { echo " "; } else { echo $destination; } ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$hours"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? if (!$charterno) { echo " "; } else { echo $charterno; }?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? if (!$charterdoll) { echo " "; } else { echo $charterdoll; } ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? if (!$comment) { echo " "; } else { echo $comment; } ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? if (!$image) { echo "N/A"; } else { echo ? $image; } ?></font></td>
</tr>
<?
++$i;
}
echo "</table>";
?>
<?
include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
mysql_select_db ("margaritaair_com");
$query = "SELECT SUM(charterdoll) AS charterpay FROM flightlog WHERE macid='MAC100'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_assoc($result);
echo '<font size="+2">Total Charter Pay: $'.$row['charterpay'];
mysql_close();
?>
The information seems to be getting to the table, but is not being displayed in the index. What appears is the path to the image on my hard drive. You can view these pages at http://www.margaritaair.com/test1.php
http://www.margaritaair.com/flightlog/index.php
Any help would be appreciated.