I am trying to make an script for uploading pictures to the proper gallery and sub gallery by using a form. First you have to select whether it's old or new (to either put the photo in the right subgallery or make a new subgallery) and select which gallery. After that you can upload the photo and it saves all the info to a MYSQL database. I know there has to be a cleaner way of doing this.
<form action="<?=$_SERVER['PHP_SELF']?>" method="POST">
<input type="radio" value="new" name="ifgallery" />New<input type="radio" value="old" name="ifgallery" checked="checked" />Old
<select size="1" name="gallery">
<option>motorcycle</option>
<option>classiccar</option>
<option>4wheel</option>
</select>
<input type="submit" value="Select Gallery" />
</form>
<form enctype="multipart/form-data" action="photo-insert.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1050000" />
<table border="0" width="100%" cellspacing="6" cellpadding="0">
<tr>
<td width="10%">Title</td>
<td width="90%"><input type="text" name="p_title" size="60"></td>
</tr>
<?php
If (isset($_POST['gallery']))
{
$gallery = $_POST['gallery'];
if (isset($_POST['ifgallery']))
{
$ifgallery = $_POST['ifgallery'];
if ($ifgallery == "new")
{
echo "<tr><td width=\"10%\">Event</td><td width=\"90%\"><input type=\"text\" name=\"p_event\" size=\"60\"></td></tr>";
echo "<tr><td width=\"10%\">Type</td><td width=\"90%\"><select size=\"1\" name=\"gallery\"><option>".$gallery."</option></select></td></tr>";
}
else
{
echo "<tr><td width=\"10%\">Event:</td><td width=\"90%\"><select size=\"1\" name=\"p_event\">";
$handle=opendir("$gallery/");
while (($file = readdir($handle))!==false) {
echo "<option>".$file."</option>";
}
closedir($handle);
echo "</select> <b>CHOOSE GALLERY!</b>
</td>
</tr>";
echo "<tr><td width=\"10%\">Type</td><td width=\"90%\"><select size=\"1\" name=\"gallery\"><option>".$gallery."</option></select></td></tr>";
}}}
?>
<tr>
<td width="10%">Year</td>
<td width="90%">
<select size="1" name="p_year">
<option>2000</option>
<option>2001</option>
<option>2002</option>
<option>2003</option>
<option>2004</option>
<option>2005</option>
<option>2006</option>
<option>2007</option>
<option>2008</option>
<option>2009</option>
<option>2010</option>
<option>2011</option>
<option>2012</option>
<option>2013</option>
<option>2014</option>
<option>2015</option>
</select>
</td>
</tr>
<tr>
<td width="10%">Description</td>
<td width="90%"><textarea rows="5" name="p_desc" cols="54"></textarea></td>
</tr>
<td width="10%">Photo</td>
<td width="90%">
<input name="uploaded_file" type="file" size="50"/>
</td>
<br /><br />
<tr><td width="10%"></td>
<td width="90%">
<input type="submit" value="Upload" /></td></form>
</tr>
</table>