-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupdate.php
More file actions
99 lines (77 loc) · 2.38 KB
/
Copy pathupdate.php
File metadata and controls
99 lines (77 loc) · 2.38 KB
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
<!--nasfk-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!-- <meta http-equiv="refresh" content="2"> -->
<link rel="stylesheet" href="Addons/updateNnewpass.css">
<title>Add Details</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<?php
// include 'session.php';
?>
<p class="pupdate">Edit Profile</p>
<hr class=hratten>
<div class="update">
<div class="tags">
<ul>
<li>Smart-Card No: </li>
<li>Reg No: </li>
<li>Name: </li>
<li>Classs/Division:</li>
<li>Roll No:</li>
<li>Mobile Number: </li>
<li>Address: </li>
</ul>
</div>
<?php
fetch();
function fetch() {
$user = 'student';
$pass = 'sakec';
$db = 'students';
$conn = new mysqli('localhost', $user, $pass, $db) or die("Unable to connect to server".$db);
$get_all = "select * from profile where UserId=\"".$_SESSION['name']."\"";
$data = mysqli_query($conn, $get_all) or die("No records found.");
$row = mysqli_fetch_assoc($data);
echo'<div class="container">
<form action="" method="POST">
<br><ul class=\"ulright\">
<li>'.$row["UserId"].'</li>
<li>'.$row["RegNo"].'</li>
<li><span>'.$row["Fname"].' '.$row["Lname"].'</span><br></li>
<li><span>'.$row["Class"].' '.$row["Division"].'</span><br></li>
<li><span>'.$row["RollNo"].'</span><br></li>
<li><input type="number" name="MobNo" value="'.$row["MobNo"].'"><br></li>
<li><input type="text" name="Addr" value="'.$row["Addr"].'"><br></li>
<input name="update" type="submit" value="Update">
<input name="pass" type="submit" value="Change Pass"></ul>
</form>
</div>';
mysqli_close($conn);
}
if (isset($_POST['pass'])) {
header('Location: home.php?page=new_pass.php');
}
if (isset($_POST['update'])) {update();}
function update() {
$user = 'student';
$pass = 'sakec';
$db = 'students';
$conn = new mysqli('localhost', $user, $pass, $db) or die("Unable to connect to server".$db);
$sql = "UPDATE `profile` SET MobNo=".$_POST['MobNo'].", Addr=\"".$_POST['Addr']."\" WHERE UserId=\"".$_SESSION['name']."\"";
if (mysqli_query($conn, $sql)) {
echo "Updated Profile, redirecting to home...";
}
else {
echo "Error: ".mysqli_error($conn);
}
mysqli_close($conn);
header("Location: home.php?page=update.php");
}
?>
</div>
</body>
</html>