Hi All.
I am having some trouble with a script which allows a user to upload a photo. When the page first loads it checks if the user has reached their maximum photo capacity. If they have then it will redirect them to another page. If they can upload more photos it will keep them on the page. Before I added this the user could select which album the photo goes into by using a drop down box. Now when I load the page, there is nothing in the drop down box. Here is the code and if anyone could help, I would be very grateful.
Thanks in advance.
Cameron
<?php
require("check_session.php");
$id = $_SESSION['id'];
$sql = mysql_query("SELECT * FROM users WHERE username='".$_SESSION['username']."'");
$sql_fetch = mysql_fetch_assoc($sql);
$row_max = $sql_fetch['max_photos'];
$row_id = $sql_fetch['id'];
$check = mysql_query("SELECT * FROM items WHERE userid='$row_id'");
$check_num = mysql_num_rows($check);
if($check_num>$row_max)
{
echo '<meta http-equiv="Refresh" Content="0; URL=maxphotos.php">';
}
?><form enctype="multipart/form-data" action="upload_picture.php" method="POST">
<table width="1019" border="0">
<tr>
<td><b>Note: Make sure you check wich album you are inserting the image into by looking at the 'Insert into album' drop down menu.</b></td>
</tr>
</table>
<table width="1020" border="0">
<tr>
<td width="418">Please choose a picture to upload</td>
<td width="16">:</td>
<td width="497"><input name="uploaded" type="file" /></td>
<td width="55"> </td>
<td width="12"> </td>
</tr>
<tr>
<td>Image Name</td>
<td>:</td>
<td><input type="text" name="imgname" /></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Description</td>
<td>:</td>
<td><textarea name="description"></textarea></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Insert into album</td>
<td> </td>
<td><select name="albumid">
<?php
$id = $_SESSION['id'];
$rs = mysql_query("SELECT * FROM albums WHERE userid='$id'");
while($row = mysql_fetch_array($rs))
{
echo "<option value=\"".$row['id']."\">".$row['name']."</option>\n ";
}
?>
</select></td>
<td><input name="upload" type="submit" id="upload" value="Upload" /></td>
<td> </td>
</tr>
<tr>
<td><b>Uploading process may take 1-2 mins depending on file size.</b></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><p> </p>
<p><b><a href="index.php">Back</a></b></p></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<br />
<?php
include("design/footer.php");
?>