-
Notifications
You must be signed in to change notification settings - Fork 2
/
editProfile.php
143 lines (119 loc) · 3.18 KB
/
editProfile.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
<?php
///error_reporting(1);
$con=mysqli_connect("localhost","root","","10am");
$sid=$_SESSION['sid'];
//include_once('connection.php');
$r=mysqli_query($con,"select * from userinfo where user_name='$sid'");
echo "<table width='940' border='1' align='center' style='background:#fff'>";
$row=mysqli_fetch_object($r);
//$p=$row->password;
$m=$row->mobile;
$e=$row->email;
echo "<tr height='50'>";
echo "<td>username :</td>";
echo "<td>".$row->user_name."</td>";
echo "</tr>";
//echo "<tr height='40'>";
//echo "<td>Password :</td>";
//echo "<td><input type='password' name='' value='$p'/></td>";
//echo "</tr>";
echo "<tr height='50'>";
echo "<td>Mobile :</td>";
echo "<td><input type='text' name='' value='$m'/></td>";
echo "</tr>";
echo "<tr height='40'>";
echo "<td>Email </td>";
echo "<td><input type='text' name='' value='$e'/></td>";
echo "</tr>";
echo "<tr height='50'>";
echo "<td>Gender :</td>";
echo "<td>".$row->gender."</td>";
echo "</tr>";
echo "<tr height='50'>";
echo "<td>Hobbies :</td>";
echo "<td>".$row->hobbies."</td>";
echo "</tr>";
echo "<tr height='50'>";
echo "<td>DOB :</td>";
echo "<td>".$row->dob."</td>";
echo "</tr>";
echo "<tr height='150'>";
echo "<td>Profile pic :</td>";
echo "<td><img style='border-radius: 100px;'alt='image not upload' src='userImages/$id/$file' height='150' width='150'/></td>";
echo "</tr>";
echo "</table>";
//echo"<input type='submit' value='change password' name='change_password'/>"
?>
<?php
//include_once('connection.php');
$con=mysqli_connect("localhost","root","","10am");
error_reporting(1);
$id=$_SESSION['sid'];
$op=$_POST['op'];
$np=$_POST['np'];
$cp=$_POST['cp'];
if(isset($_POST['chngP']))
{
function encryptIt($q){
$cryptKey = 'qJB0rGtIn5UB1xG03efyCp';
$qEncoded = base64_encode( mcrypt_encrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), $q,MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ) );
return( $qEncoded );
}
$encrypted = encryptIt($op);
if($op=="" || $np=="" || $cp=="")
{
$err="Fill all the fields first";
}
else
{
$sql="select * from userinfo where user_name ='$id'";
$d=mysqli_query($con,$sql);
list($a,$b,$c)=mysqli_fetch_array($d);
if($c==$encrypted)
{
if($np==$cp)
{
$newencrypted = encryptIt($np);
$sql="update userinfo set password='$newencrypted' where user_name='$id'";
$d=mysqli_query($con,$sql);
echo "<script>alert('Password updated');</script>";
}
else
{
echo "<script>alert('New password not matching');</script>";
}
}
else
{
echo "<script>alert('Wrong old password');</script>";
}
}
}
?>
<body>
<form method="post">
<table width="940" align='center' border="1" style='background:#fff'>
<tr>
<?php echo $err; ?>
<th width="173" height="40" scope="row">Old Password </th>
<td width="176">
<input type="password" name="op"/>
</td>
</tr>
<tr>
<th height="40" scope="row">New Password </th>
<td>
<input type="password" name="np"/>
</td>
</tr>
<tr>
<th height="40" scope="row">Confirm Password </th>
<td><input type="password" name="cp"/></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="chngP" value="Change Password"/></td>
</tr>
</table>
</form>
</body>