-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdater.php
50 lines (41 loc) · 1.68 KB
/
updater.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
<html>
<body>
<?php
session_start();
if ( isset( $_SESSION['user_id'] ) ) {
$idh=$_SESSION['user_id'];
} else {echo 'session expired.';
header("Refresh:0; URL=expiredsess.php");
die();
}
include 'connection.php';
$query="";
$userid=$_SESSION['user_id'];
if(!empty($_POST['name'])){
$query .= "UPDATE login SET name='".$_POST['name']."' WHERE username='".$userid."';";
}
if(!empty($_POST['phone'])){
$query .= "UPDATE login SET mob='".$_POST['phone']."' WHERE username='".$userid."';";
}
if(!empty($_POST['answer']) && $_POST['secques']!='empty'){
$query .= "UPDATE login SET secques='".$_POST['secques']."' WHERE username='".$userid."';";
$query .="UPDATE login SET answer='".$_POST['answer']."' WHERE username='".$userid."'";
}
if(!empty($_POST['answer']) && $_POST['secques']=='empty'){
echo"<script type='text/javascript'> { alert('Error: No Security Question selected.');} window.location.replace('profile.php');</script>";
}
if(empty($_POST['answer']) && $_POST['secques']!='empty'){
echo"<script type='text/javascript'> { alert('Error: No answer given for selected security question.');} window.location.replace('profile.php');</script>";
}
mysqli_multi_query($conn, $query);
if(mysqli_affected_rows($conn)>0)
{
echo"<script type='text/javascript'> { alert('Update Successful..!');} window.location.replace('profile.php');</script>";
}
else{
echo"<script type='text/javascript'> { alert('Nothing Updated.');} window.location.replace('profile.php');</script>";
}
mysqli_close($conn);
?>
</body>
</html>