-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_profile.php
59 lines (55 loc) · 1.32 KB
/
edit_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
<?php
//edit_profile.php
include('database_connection.php');
if(isset($_POST['user_name']))
{
if($_POST["user_new_password"] != '')
{
$query = "
UPDATE user_details SET
user_name = '".$_POST["user_name"]."',
user_email = '".$_POST["user_email"]."',
user_password = '".password_hash($_POST["user_new_password"], PASSWORD_DEFAULT)."'
WHERE user_id = '".$_SESSION["user_id"]."'
";
}
else
{
$query = "
UPDATE user_details SET
user_name = '".$_POST["user_name"]."',
user_email = '".$_POST["user_email"]."'
WHERE user_id = '".$_SESSION["user_id"]."'
";
}
/*
if(isset($_FILES['profileImage']))
{
$targetFile =
}
*/
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
if(isset($result))
{
echo '<div class="alert alert-success">Profile Edited</div>';
}
}
//if(isset($_POST['add_image'])){
if(isset($_POST['profieImage'])){
$file = addslashes(file_get_contents($_FILES['profieImage']['tmp_name']));
$query = "
UPDATE user_details SET
image = '".$file."'
WHERE user_id = '".$_SESSION["user_id"]."';
";
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->rowCount();
if($result >= 1){
//echo "<script>alert('Image Added in DB');</script>";
echo '<div class="alert alert-success">Image Added</div>';
}
}
?>