Hi im having abit of trouble adapting a tutorial i found on nettuts for creating a photography website heres the link if you wanna check it out:
http://net.tutsplus.com/videos/screencasts/building-the-back-end-of-a-photo-site/
Anyways this code is fine, although because i have several categories of photos i need to store them in seperate tables, was wondering if i could use a drop down box to let the user choose the table where they want the photos to go. Any help is greatly appreciated.
ive posted the code below for the admin page. i included the select box i just dont have a clue on the php side of things thanks again.
<?php
require 'config.php';
require 'functions.php';
require 'common.php';
if(isset($_FILES['fupload'])) {
$filename = addslashes($_FILES['fupload']['name']); //get image user inputs
$source = $_FILES['fupload']['tmp_name']; // temp directory where image is stored
$target = $path_to_image_directory . $filename;
$description = addslashes($_POST['description']);
$src = $path_to_image_directory . $filename;
$tn_src = $path_to_thumbs_directory . $filename;
// Validates the form input
if(strlen($_POST['description']) < 5) // validates user inputted something larger than 5 characters long
$error['description'] = '<p class="alert">Please enter a description for the photo. </p>';
if($filename == '' || !preg_match('/[.](jpg)|(gif)|(png)|(jpeg)$/', $filename)) // check user chose a picture to upload
$error['no_file'] = '<p class="alert">Please select an image to upload </p>';
if(!$error) {
move_uploaded_file($source, $target); // move image from temporary directory
$q = "INSERT into photo(description, src, tn_src) VALUES('$description', '$src', '$tn_src')"; //update database
$result = $mysqli->query($q) or die(mysqli_error($mysqli));
if($result) {
echo "Your Photograph has been uploaded";
}
createThumbnail($filename);
} // end preg_match
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="css/default.css" />
<title>My Photos</title>
</head>
<body>
<h1>My Photos</h1>
<ul><?php getPhotos(); ?></ul>
<h1>Upload a Photo</h1>
<form enctype="multipart/form-data" method="post" action="admin.php">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<p><input type="file" name="fupload" /></p>
<p><label for="description">Enter a Description: </label>
<textarea rows="6" cols="50" id="description" name="description"></textarea></p>
<p> <select name="catagory">
<option value="sports">Sports</option>
<option value="london">London</option>
<option value="macro">Macro</option>
<option value="landscapes">Landscapes</option>
<option value="local">Local</option>
</select>
<p><input type="submit" value="Upload Photo" name="submit" /></p>
</form>
<?php
if ($error['no_file']) echo $error['no_file'];
if ($error['no_catagory']) echo $error['no_catagory'];
if ($error['description']) echo $error['description'];
?>
<br />
<a href="deletephoto.php">Delete A Photo</a>
</body>
</html>