-
Notifications
You must be signed in to change notification settings - Fork 1
/
image.php
39 lines (35 loc) · 962 Bytes
/
image.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
session_start();
if(!$_SESSION['auth']){
header('location: index.php');
}
else{
if($_POST){
include('connection.php');
$user_id = $_SESSION['user_id'];
$query = "SELECT COUNT(*) as count FROM image_data WHERE user_id = $user_id";
$result = mysqli_query($conn, $query);
while($row=$result->fetch_assoc()){
$count = $row['count'];
}
$count = $count + 1;
echo $user_id;
echo $count;
$filename = $user_id."_".$count.".png";
$filetmp = $_FILES['image']['tmp_name'];
$filetype = $_FILES['image']['type'];
$filepath = "user_images/".$filename;
move_uploaded_file($filetmp, $filepath);
date_default_timezone_set('Asia/Kolkata');
$time = date('Y-m-d H:i:s');
$sql = "INSERT INTO image_data VALUES (null, '$filename','','', '$time', $user_id)";
$res = mysqli_query($conn, $sql);
if($res){
header("location: result.php");
}
else{
echo "Data not entered";
}
}
}
?>