This script is working fine.. but i just wonder how do i change the value insert into database if no image selected to value "none" instead of random words like 15199660151398490708
<?php
$name = ''; $type = ''; $size = ''; $error = '';
$upload = "asssets/img/";
$new = time().rand();
$target = $upload . $new . basename( $_FILES['photo']['name']);
require_once('includes/config.php');
// If form submitted, insert values into the database.
if(isset($_POST['submit']) && !empty($_POST['submit'])) {
$pic=$new .($_FILES['photo']['name']);
$query = "INSERT INTO posting(photo) VALUES('$pic')";
$result = mysql_query($query);
//Writes the photo to the server
if (($_FILES["photo"]["type"] == "image/gif") ||
($_FILES["photo"]["type"] == "image/jpeg") ||
($_FILES["photo"]["type"] == "image/png") ||
($_FILES["photo"]["type"] == "image/pjpeg")) {
$filename = compress_image($_FILES["photo"]["tmp_name"], $target, 80);
{
echo "";
}
}else
echo "";{
?><form method="post" style="padding:0px;margin:0px;display: block;" enctype="multipart/form-data" autocomplete="off">
<input name="photo" type="file" accept="image/*">
<input name="submit" class="button_post" id="click" type="submit" value=" Post" />
</form><?php } ?>