-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile_submit.php
62 lines (52 loc) · 1.79 KB
/
profile_submit.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
<?php
session_start();
if (isset($_POST['submit'])) {
require "dbconnection/database.php";
$user_id = $_POST['user_id'];
$target_dir = 'images/';
$myprofile = $_FILES['myprofile']['name'];
$target_dir .= $myprofile;
$tmp_dir = $_FILES['myprofile']['tmp_name'];
$size = $_FILES['myprofile']['size'];
$type = $_FILES['myprofile']['type'];
$ext = pathinfo($myprofile, PATHINFO_EXTENSION);
$username = $_POST['username'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$gender = $_POST['gender'];
$password = $_POST['password'];
$c_password = $_POST['c_password'];
$role = 'user';
$join_date = date('Y-m-d');
if ($password !== $c_password) {
header("location:profile.php?password_error");
exit;
}
if ($ext === 'png' or $ext === 'jpg' or $ext === 'jpeg' or $ext === 'PNG' or $ext === 'JPG' or $ext === 'JPEG') {
$uploaded = move_uploaded_file($tmp_dir, $target_dir);
if ($uploaded) {
$sql = "UPDATE
tbl_user
SET
username = '$username',
email = '$email',
phone = '$phone',
gender = '$gender',
image = '$target_dir',
password = '$password'
WHERE
user_id = $user_id
";
$stmt = $conn->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
header('location:profile.php?updated');
} else {
header('location:profile.php?not_updated');
}
}
} else {
header('location:profile.php?invalid_extention');
}
$stmt = null;
}