-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.php
72 lines (61 loc) · 2.5 KB
/
profile.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
include ("conn.php");
if (isset($_POST['upload'])) {
$id = $_GET['id'];
$file_name = $_FILES['file']['name'];
$file_temp = $_FILES['file']['tmp_name'];
$file_size = $_FILES['file']['size'];
$file_type = $_FILES['file']['type'];
$location = "upload/" . $file_name;
if ($file_size < 524000) {
if (move_uploaded_file($file_temp, $location)) {
try {
$db->setAttribute(PDO::ATTR_ERRMODE);
$sql = "UPDATE users SET Photo='$location' WHERE id = '$id'";
$db->exec($sql);
} catch (Exception $e) {
echo $e->getMessage();
}
$db = null;
header('location:index.php');
}
} else {
echo "<script>alert('File size is too large to upload')";
}
}
?>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<!-- font awesome scripti -->
<script src="https://kit.fontawesome.com/49b70e1494.js" crossorigin="anonymous"></script>
<!-- bootstrapdan alindi css scripti -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>
<body>
<?php
$id = $_GET['id'];
$sql = "SELECT * FROM users WHERE id = '$id'";
$query = $db->prepare($sql);
$result = $query->execute();
$result = $query->fetch();
?>
<div class="container">
<div class="row">
<div class="col-md-12">
<h4>Profile Upload</h4>
<form method="POST" enctype="multipart/form-data">
<div class="form-group">
<label>Upload Here</label>
<input type="file" name="file" class="form-control" required>
</div>
<button type="submit" name="upload" class="btn btn-danger">Upload</button>
</form>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</body>
</html>