This repository has been archived by the owner on Aug 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
update.php
50 lines (39 loc) · 1.82 KB
/
update.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
<?php
$conn = new mysqli("localhost","id3320560_root_lol","lol1234","id3320560_organd");
if($conn->connect_error)
die("Connection failed".$conn->connect_error);
$name = $_POST["name"];
$username = $_POST["username"];
$email = $_POST["email"];
$dob = $_POST["dob"];
$don_type = $_POST["don_type"];
$blood_type = $_POST["blood_type"];
$med_cer = basename( $_FILES['file']['name']);
// echo "<script>alert('".$med_cer."');</script>";
$up=1;
$update_q = "UPDATE user SET name='$name', email='$email', dob='$dob', don_type='$don_type', blood_type='$blood_type'WHERE username = '$username'";
$_SESSION["name"]=$name;
// echo $_SESSION["name"];
$res = $conn->query($update_q);
if(strlen($med_cer)>0){
$update_m = "UPDATE user SET med_cer='$med_cer'WHERE username = '$username'";
$medres = $conn->query($update_m);
$targetfolder = "uploads/";
$targetfolder = $targetfolder . basename( $_FILES['file']['name']) ;
if(move_uploaded_file($_FILES['file']['tmp_name'], $targetfolder))
{
echo "<script>alert('The file ". basename( $_FILES['file']['name']). " is uploaded');</script>";
echo "<script>alert('Your details were Successfully updated');</script>";
echo $_SESSION["name"];
echo "<script>window.location.replace('index.php')</script>";
}
else {
$up=0;
echo "<script>alert('Problem uploading');</script>";
echo "<script>window.location.replace('user-profile.php')</script>";
}
}
if($up==1)
echo "<script>alert('Your details were Successfully updated');</script>";
echo "<script>window.location.replace('index.php')</script>";
?>