Hi, everyone
I am trying to upload image name into database and the image to specified file directory and also textbox values are insert into database so, below is my code please tell me what is wrong with this code.
Thank in advance.
$target_Path = "images/"; //storing image path.
$filename = 'user_file';
$target_Path .= $filename["user_file"];
$ToiletId = "anythning";
$target_Path = $target_Path.basename( $_FILES['user_file']['name'] );
move_uploaded_file( $_FILES['user_file']['tmp_name'], $target_Path );
include('dbconfig.php');
include ('userid.php');
if (isset($_POST['Toilet_Id'], $_POST['submit'])) {
$toiletid = $_POST['Toilet_Id'];
$cleanedrooms = $_POST['cleanedrooms'];
$description = $_POST['description'];
$user_file = $_POST['user_file'];
$submit = $_POST['submit'];
$sql = "SELECT * FROM Toilet where [ToiletID] = '$toiletid' ";
$result = sqlsrv_query($conn, $sql);
while($row = sqlsrv_fetch_array($result)){
$toiletid = $row['ToiletID'];
$toiletname = $row['ToiletName'];
$totalrooms = $row['ToiletRooms'];
}
if(empty($_POST['cleanedrooms']) && empty($_POST['description'])
&& empty($_POST['userfile']))
{
echo "";
}
else {
$query = "INSERT INTO [Toilet_Clean_Status] (
[ToiletID],
[cleanRooms],
[description],
[Updatedby],
[UpdatedDate],
[image])
VALUES ('$toiletid',
'$cleanedrooms',
'$description',
'$user',
getdate(),
'$ImageName')";
}
}
?>
Toilet Clean Status
$filename = 'user_file';
$target_Path .= $filename["user_file"];
$ToiletId = "anythning";
$target_Path = $target_Path.basename( $_FILES['user_file']['name'] );
move_uploaded_file( $_FILES['user_file']['tmp_name'], $target_Path );
include('dbconfig.php');
include ('userid.php');
if (isset($_POST['Toilet_Id'], $_POST['submit'])) {
$toiletid = $_POST['Toilet_Id'];
$cleanedrooms = $_POST['cleanedrooms'];
$description = $_POST['description'];
$user_file = $_POST['user_file'];
$submit = $_POST['submit'];
$sql = "SELECT * FROM Toilet where [ToiletID] = '$toiletid' ";
$result = sqlsrv_query($conn, $sql);
while($row = sqlsrv_fetch_array($result)){
$toiletid = $row['ToiletID'];
$toiletname = $row['ToiletName'];
$totalrooms = $row['ToiletRooms'];
}
if(empty($_POST['cleanedrooms']) && empty($_POST['description'])
&& empty($_POST['userfile']))
{
echo "";
}
else {
$query = "INSERT INTO [Toilet_Clean_Status] (
[ToiletID],
[cleanRooms],
[description],
[Updatedby],
[UpdatedDate],
[image])
VALUES ('$toiletid',
'$cleanedrooms',
'$description',
'$user',
getdate(),
'$ImageName')";
}
}
?>
Upendra Pratap ShahiPosted Jun 14, 2015, 1:47 AM