I have a problem which is when I try to insert the value of the Get['id'], I always get a 0 even tho when I print the id! I can see it. Upload.php: Hello there, I have a problem which is when I try to insert the value of the Get['id'], I always get a 0 even tho when I print the id! I can see it. Upload.php:
<?php
include '../include/connect.php';
$id =(int)$_GET['id'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="file_img" />
<input type="submit" name="btn_upload" value="Upload">
</form>
<?php
if(isset($_POST['btn_upload']))
{
$filetmp = $_FILES["file_img"]["tmp_name"];
$filename = $_FILES["file_img"]["name"];
$filetype = $_FILES["file_img"]["type"];
$filepath = "photo/".$filename;
move_uploaded_file($filetmp,$filepath);
$sql = "INSERT INTO upload_img (img_name,img_path,img_type,im_id) VALUES ('$filename','$filepath','$filetype','.$id.')";
mysqli_query($con, $sql);
}
?>
</body>
</html>
and my sql:
A photo of the database
I tried using this link :
upload.php?id=2