-
Notifications
You must be signed in to change notification settings - Fork 0
/
editprocess.php
175 lines (159 loc) · 6.97 KB
/
editprocess.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
session_start();
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
require 'connection.php';
if(!($_SESSION["username"]==true)||$_SESSION['method']==="signup"||!($_SESSION['profile']==="complete"))
{
header("location:login.php");
}
else
{ if(isset($_POST['submit']))
{
if(empty($_POST['mobile'])||empty($_POST['address'])||empty($_POST['occupation'])||empty($_POST['institute'])||empty($_POST['about'])||empty($_POST['email'])||empty($_POST['pass'])||empty($_POST['sex'])||empty($_POST['dob']))
echo "<script>alert('Some input missing!!')</script>";
else
{
$email=$_POST['email'];
$sex=$_POST['sex'];
$dob=$_POST['dob'];
$phone=$_POST['mobile'];
$password=$_POST['pass'];
$address=$_POST['address'];
$about=$_POST['about'];
$occupation=$_POST['occupation'];
$institute=$_POST['institute'];
$method=$_SESSION['method'];
$username=$_SESSION['username'];
$query1="select password from ruddi_user where username='$username'";
$query_run1=$conn->query($query1);
while($row= $query_run1->fetch_assoc())
{
if(password_verify($password,$row['password']))
{
if(empty($_POST['npass'])&&empty($_POST['cpass']))
{
$query="update ruddi_user set email='$email',sex='$sex',dob='$dob' where username='$username'";
$query_run=$conn->query($query);
if($query_run){
if($_FILES['myFile']['size'] == 0 )
{
$query="update ruddi_profile set phonenumber='$phone',address='$address',about='$about',institute='$institute',occupation='$occupation' where username='$username'";
$query_run=$conn->query($query);
if( $query_run)
{ echo "<script>alert('Updated Successfully')</script>";
echo "<script>window.location.href = 'dashboard.php';</script>";
}
else
{ echo "<script>alert('Try again later')</script>";
echo "<script>window.location.href = 'edit.php';</script>";
}
}
else
{
$myFile=$_FILES["myFile"];
$myFile_name=$_FILES["myFile"]['name'];
$myFile_type=$_FILES["myFile"]["type"];
$myFile_temploc=$_FILES["myFile"]["tmp_name"];
$myFile_stor="profilepics/".time().'_'.$_FILES['myFile']['name'];
$ext=explode('.', $myFile_name);
$actualExt=strtolower(end($ext));
if($actualExt=='jpg'||$actualExt=='jpeg'||$actualExt=='gif'||$actualExt=='png'||$actualExt=='svg')
{
move_uploaded_file($myFile_temploc, $myFile_stor);
$query="update ruddi_profile set phonenumber='$phone',address='$address',about='$about',institute='$institute',occupation='$occupation',profile='$myFile_stor' where username='$username'";
$query_run=$conn->query($query);
if( $query_run)
{ echo "<script>alert('Updated Successfully')</script>";
echo "<script>window.location.href = 'dashboard.php';</script>";
}
else
{ echo "<script>alert('Try again later')</script>";
echo "<script>window.location.href = 'edit.php';</script>";
}
}
else
echo "<script>alert('Check Extension of uploaded file')</script>";
}
}
else
{ echo "<script>alert('Try again later')</script>";
echo "<script>window.location.href = 'edit.php';</script>";
}
}
else if(empty($_POST['npass'])||empty($_POST['cpass'])){
echo "<script>alert('Your new password or confirm password missing!!')</script>";
}
else
{
if($_POST['cpass']===$_POST['npass'])
{
$hash=password_hash($_POST['cpass'],PASSWORD_DEFAULT);
$query="update ruddi_user set email='$email',sex='$sex',dob='$dob',password='$hash' where username='$username'";
$query_run=$conn->query($query);
if($query_run){
if($_FILES['myFile']['size'] == 0)
{
$query="update ruddi_profile set phonenumber='$phone',address='$address',about='$about',institute='$institute',occupation='$occupation' where username='$username'";
$query_run=$conn->query($query);
if( $query_run)
{ echo "<script>alert('Updated Successfully')</script>";
echo "<script>window.location.href = 'dashboard.php';</script>";
}
else
{ echo "<script>alert('Try again later')</script>";
echo "<script>window.location.href = 'edit.php';</script>";
}
}
else
{
$myFile=$_FILES["myFile"];
$myFile_name=$_FILES["myFile"]['name'];
$myFile_type=$_FILES["myFile"]["type"];
$myFile_temploc=$_FILES["myFile"]["tmp_name"];
$myFile_stor="profilepics/".time().'_'.$_FILES['myFile']['name'];
$ext=explode('.', $myFile_name);
$actualExt=strtolower(end($ext));
if($actualExt=='jpg'||$actualExt=='jpeg'||$actualExt=='gif'||$actualExt=='png'||$actualExt=='svg')
{
move_uploaded_file($myFile_temploc, $myFile_stor);
$query="update ruddi_profile set phonenumber='$phone',address='$address',about='$about',institute='$institute',occupation='$occupation',profile='$myFile_stor' where username='$username'";
$query_run=$conn->query($query);
if( $query_run)
{ echo "<script>alert('Updated Successfully')</script>";
echo "<script>window.location.href = 'dashboard.php';</script>";
}
else
{ echo "<script>alert('Try again later')</script>";
echo "<script>window.location.href = 'edit.php';</script>";
}
}
else
{echo "<script>alert('Check Extension of uploaded file')</script>";
echo "<script>window.location.href = 'edit.php';</script>";
}
}
}
else
{ echo "<script>alert('Try again later')</script>";
echo "<script>window.location.href = 'edit.php';</script>";
}
}
else
{ echo "<script>alert('Your new password and confirm not matching')</script>";
echo "<script>window.location.href = 'edit.php';</script>";
}
}
}
else
{ echo "<script>alert('Check Your Password')</script>";
echo "<script>window.location.href = 'edit.php';</script>";
}
}
}
}
else
echo "Invalid Request";
}
?>