Sorry, I guess that's what happens when you stare at code for hours. Here is the rest of the code which is above what I posted earlier
//This gets all the other information from the form
$id = isset($_POST['Id']) ? $_POST['Id'] : 'NULL';
$date = isset($_POST['Date']) ? $_POST['Date'] : '';
$mls = isset($_POST['Mls']) ? $_POST['Mls'] : '';
$address = isset($_POST['Address']) ? $_POST['Address'] : '';
$beds = isset($_POST['Beds']) ? $_POST['Beds'] : '';
$baths = isset($_POST['Baths']) ? $_POST['Baths'] : '';
$year = isset($_POST['Year']) ? $_POST['Year'] : '';
$sqft = isset($_POST['Sqft']) ? $_POST['Sqft'] : '';
$price = isset($_POST['Price']) ? $_POST['Price'] : '';
$area = isset($_POST['Area']) ? $_POST['Area'] : '';
$details = isset($_POST['Details']) ? $_POST['Details'] : '';
$status = isset($_POST['Status']) ? $_POST['Status'] : '';
$photo=($_FILES['photo']['name']);
// Connects to your Database
require('dbcadmin.php');
//Writes the information to the database
$stmt = $conn->prepare("INSERT INTO listings (id, date, mls, address, photo, beds, baths, year, sqft, price, area, details, status) \n".
" VALUES (:id, :date, :mls, :address, :photo, :beds, :baths, :year, :sqft, :price, :area, :details, :status) ");
$success = $stmt->execute(array(':id'=>$id, ':date'=>$date, ':mls'=>$mls, ':address'=>$address, ':photo'=>$photo, ':beds'=>$beds, ':baths'=>$baths, ':year'=>$year, ':sqft'=>$sqft, ':price'=>$price, ':area'=>$area, ':details'=>$details, ':status'=>$status));
/////////Create a directory from mls number Change $dirpath = images/ to where you want the Directory created
$folder = $_POST['Mls'];
$dirPath = "images/".$folder;
$result = mkdir($dirPath, 0755);
if ($result == 1) {
echo "<center><h3> A new folder ";
echo $dirPath . " has been created</h3>";
echo "<center><h4><a href='listview.php'>View Listing</a>";
} else {
echo "<center><h3> There was an ERROR new folder ";
echo $dirPath . " has NOT been created</h3>";
echo "<center><h4><a href='listadd.php'>Go Back</a>";
}
Like I said it all works fine if a file is uploaded the name goes in the photo field in the db but if no photo is uploaded then that field is empty. And I want it to put images/picholder.jpgthere.
Thanks