-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile_view.php
executable file
·95 lines (73 loc) · 4.59 KB
/
profile_view.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
<?php
session_start();
include 'templates/header.php' ?>
<?php include 'templates/navbar.php' ?>
<?php
function addcss(){
echo '<link rel="stylesheet" type="text/css" href="styles/forms.css">';
}?>
<?php
include 'templates/db-con.php';
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
if(isset($_GET['method']) && $_GET['method']=='insert' && $_SESSION['role']=='admin')
{
$flag = '';
$method = 'insert';
}
else
{
$method = 'update';
$flag = 'true';
if($_SESSION['role'] == 'admin')
$user = $_GET['user_id'];
else
$user = $_SESSION['uname'];
$sql = "SELECT * from person where user_id = '$user'";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
mysqli_close($conn);
}
?>
<form id="profile" action="edit_profile.php?method=<?php echo $method; ?>" name="profile" method="post" style = "font-size: 15px; width: 500px; margin: 0 auto">
<div class="form-group" style="margin:10px 0px 10px; font-size: inherit;">
<label for="fname">First Name:<span style="color : red"> * </span></label>
<input type="text" class="form-control" style="margin:10px 0px 10px; font-size: inherit;" name="fname" id="fname" value="<?php if($flag) echo $row ['fname']; ?>" <?php if($_SESSION['role'] != 'admin') echo "readonly" ?> required pattern="[a-zA-z]+$">
<label for="lname">Last Name:</label>
<input type="text" class="form-control" style="margin:10px 0px 10px; font-size: inherit;" name="lname" id="lname" value="<?php if($flag) echo $row ['lname']; ?>" <?php if($_SESSION['role'] != 'admin') echo "readonly" ?> pattern="[A-Za-z]+$">
<label for="contact">Mobile no.: <span style="color : red"> * </span></label>
<input type="text" class="form-control" style="margin:10px 0px 10px; font-size: inherit;" name="contact" id="contact" value="<?php if($flag) echo $row ['contact']; ?>" <?php if($_SESSION['role'] != 'admin') echo "readonly" ?> required pattern="[0-9]{10}$">
<label for="email">Email-Id:</label>
<input type="email" class="form-control" style="margin:10px 0px 10px; font-size: inherit;" name="email" id="email" value="<?php if($flag) echo $row ['email']; ?>" <?php if($_SESSION['role'] != 'admin') echo "readonly" ?>>
<label for="fname">Username:<span style="color : red"> * </span></label>
<span id="correct" class="glyphicon glyphicon-ok" style="color:green;display:none;"></span>
<div id = "wrong" style="display:none;"><span class="glyphicon glyphicon-remove" style="color:red;"></span> Already Taken!</div>
<input type="text" class="form-control" style="margin:10px 0px 10px; font-size: inherit;" name="uname" onkeyup="uname_availability(this.value)" value="<?php if($flag) echo $row ['user_id']; ?>" <?php if($flag) echo 'readonly' ?>>
<label for="pwd">Password<span style="color : red"> * </span></label>
<input type="text" class="form-control" style="margin:10px 0px 10px; font-size: inherit;" name="pwd" id="pwd" value="<?php if($flag) echo $row ['pwd']; ?>" <?php if($_SESSION['role'] != 'admin') echo "readonly" ?> required minlength="8">
<?php if($_SESSION['role']=='admin')
{
echo '<label for="role">Role:<span style="color : red"> * </span></label>
<input type="text" class="form-control" list="role-types" style="margin:10px 0px 10px; font-size: inherit;" name="role" value="';
if($flag)
echo $row ['role'];
echo '">';
}
?>
<datalist id="role-types">
<option value="Customer"></option>
<option value="Manager"></option>
<option value="admin"></option>
</datalist>
<div id = "editable" <?php if($_SESSION['role'] != 'admin') echo 'style = "display:none"' ?>>
<button type="submit" id = "submit" class="btn btn-primary" style="font-size: 13px">Update Profile</button>
<button type="button" id = "cancel" class="btn btn-primary" style="font-size: 13px" onclick="location.reload()" >Cancel</button>
</div>
<?php
if($_SESSION['role'] != 'admin')
echo '<button type="button" id = "edit" class="btn btn-primary" style="font-size: 13px" onclick="setEdit()" >Edit Info</button>';?>
</div>
</form>
<?php include 'templates/footer.php' ?>