-
Notifications
You must be signed in to change notification settings - Fork 0
/
editing.php
91 lines (67 loc) · 2.13 KB
/
editing.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
session_start();
if(!(isset($_SESSION["logged"]) && $_SESSION["logged"] === true)){
header("location: loginregister.html");
exit;
}
?>
<?php
$name=($_POST["name"]);
$phone=($_POST["phone"]);
$dob=($_POST["dob"]);
$email=($_POST["email"]);
$username=($_POST["username"]);
$pass=($_POST["password1"]);
$pass2=($_POST["password2"]);
$img=addslashes(file_get_contents($_FILES["pic"]["tmp_name"]));
if($pass==$pass2){
/*
echo ("Name: ".$name.'<br>');
echo ("Phone: ".$phone.'<br>');
echo ("DOB: ".$dob.'<br>');
echo ("Email: ".$email.'<br>');
echo ("Username: ".$username.'<br>');
echo ("Password: ".$pass.'<br>');
*/
$host="localhost";
$user="root";
$password="";
$database="titan";
$hashedpass= (password_hash($pass, PASSWORD_DEFAULT));
$connection=new mysqli("$host", "$user", "$password", "$database");
if(!$connection){
die ("Connection Failed: ".$connection->connect_error);
}
$sql=("DELETE FROM members WHERE username='$username'");
$delete=($connection->query($sql));
if($delete){
$sql=("INSERT INTO members(name, phone, dob, email, username, pass, image) VALUES('$name', '$phone', '$dob', '$email', '$username', '$hashedpass', '$img')");
$insert=($connection->query($sql));
if($insert){
echo "<script language='javascript' type='text/javascript'>";
echo "alert('Details submitted successfully! You can now Log in');";
echo "</script>";
$URL="logout.php";
echo "<script>location.href='$URL'</script>";
}else{
echo "<script language='javascript' type='text/javascript'>";
echo "alert('Details submission failed! Please try again.');";
echo "</script>";
$URL="edit.php";
echo "<script>location.href='$URL'</script>";
}
}else{
echo "<script language='javascript' type='text/javascript'>";
echo "alert('Details submission failed! Please try again.');";
echo "</script>";
$URL="edit.php";
echo "<script>location.href='$URL'</script>";
}
}else{
echo "<script language='javascript' type='text/javascript'>";
echo "alert('The passwords do not match, Please try again');";
echo "</script>";
$URL="edit.php";
echo "<script>location.href='$URL'</script>";
}
?>