-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_cashier.php
executable file
·203 lines (177 loc) · 7.47 KB
/
admin_cashier.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?php
session_start();
include_once('connect_db.php');
if(isset($_SESSION['username'])){
$id=$_SESSION['admin_id'];
$username=$_SESSION['username'];
}else{
header("location:http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/index.php");
exit();
}
if(isset($_POST['submit'])){
$fname=$_POST['first_name'];
if (!preg_match("/^[a-zA-Z ]*$/",$fname))
{
$nameErr = "Only letters and white space allowed";
}
$lname=$_POST['last_name'];
$sid=$_POST['staff_id'];
$postal=$_POST['postal_address'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$user=$_POST['username'];
$pas=$_POST['password'];
$sql1=mysql_query("SELECT * FROM cashier WHERE username='$user'")or die(mysql_error());
$result=mysql_fetch_array($sql1);
if($result>0){
$message="<font color=blue>sorry the username entered already exists</font>";
}else{
$sql=mysql_query("INSERT INTO cashier(first_name,last_name,staff_id,postal_address,phone,email,username,password,date)
VALUES('$fname','$lname','$sid','$postal','$phone','$email','$user','$pas',NOW())");
if($sql>0) {header("location:http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/admin_cashier.php");
}else{
$message1="<font color=red>Registration Failed, Try again</font>";
}
}}
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $username;?>Agadi Sunrise Hospital</title>
<link rel="stylesheet" type="text/css" href="style/mystyle.css">
<link rel="stylesheet" href="style/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="style/table.css" type="text/css" media="screen" />
<script src="js/function.js" type="text/javascript"></script>
<script src="js/validation_script.js" type="text/javascript"></script>
<!--<script>
function validateForm()
{
//for alphabet characters only
var str=document.form1.first_name.value;
var valid="abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//comparing user input with the characters one by one
for(i=0;i<str.length;i++)
{
//charAt(i) returns the position of character at specific index(i)
//indexOf returns the position of the first occurence of a specified value in a string. this method returns -1 if the value to search for never ocurs
if(valid.indexOf(str.charAt(i))==-1)
{
alert("First Name Cannot Contain Numerical Values");
document.form1.first_name.value="";
document.form1.first_name.focus();
return false;
}}
if(document.form1.first_name.value=="")
{
alert("Name Field is Empty");
return false;
}
//for alphabet characters only
var str=document.form1.last_name.value;
var valid="abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//comparing user input with the characters one by one
for(i=0;i<str.length;i++)
{
//charAt(i) returns the position of character at specific index(i)
//indexOf returns the position of the first occurence of a specified value in a string. this method returns -1 if the value to search for never ocurs
if(valid.indexOf(str.charAt(i))==-1)
{
alert("Last Name Cannot Contain Numerical Values");
document.form1.last_name.value="";
document.form1.last_name.focus();
return false;
}}
if(document.form1.last_name.value=="")
{
alert("Name Field is Empty");
return false;
}
}
</script>-->
<style>
<style>#left-column {height: 477px;}
#main {height: 477px;}</style>
</style>
</head>
<body>
<div id="content">
<div id="header">
<h1><a href="#"><img src="images/ash.gif"></a>Agadi Sunrise Hospital</h1></div>
<div id="left_column">
<div id="button">
<ul>
<li><a href="admin.php">Dashboard</a></li>
<li><a href="admin_pharmacist.php">Pharmacist</a></li>
<li><a href="admin_manager.php">Manager</a></li>
<li><a href="admin_cashier.php">Cashier</a></li>
<li><a href="logout.php">Logout</a></li>
</ul>
</div>
</div>
<div id="main">
<div id="tabbed_box" class="tabbed_box">
<h4>Manage Cashier</h4>
<hr/>
<div class="tabbed_area">
<ul class="tabs">
<li><a href="javascript:tabSwitch('tab_1', 'content_1');" id="tab_1" class="active">View User</a></li>
<li><a href="javascript:tabSwitch('tab_2', 'content_2');" id="tab_2">Add User</a></li>
</ul>
<div id="content_1" class="content">
<?php echo $message;
echo $message1;
/*
View
Displays all data from 'Cashier' table
*/
// connect to the database
include_once('connect_db.php');
// get results from database
$result = mysql_query("SELECT * FROM cashier")
or die(mysql_error());
// display data in table
echo "<table border='1' cellpadding='5' align='center'>";
echo "<tr> <th>ID</th><th>Firstname </th> <th>Lastname </th> <th>Username </th><th>Update </th><th>Delete</th></tr>";
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array( $result )) {
// echo out the contents of each row into a table
echo "<tr>";
echo '<td>' . $row['cashier_id'] . '</td>';
echo '<td>' . $row['first_name'] . '</td>';
echo '<td>' . $row['last_name'] . '</td>';
echo '<td>' . $row['username'] . '</td>';
?>
<td><a href="update_cashier.php?username=<?php echo $row['username']?>"><img src="images/update-icon.png" width="35" height="35" border="0" /></a></td>
<td><a href="delete_cashier.php?cashier_id=<?php echo $row['cashier_id']?>"><img src="images/delete-icon.jpg" width="35" height="35" border="0" /></a></td>
<?php
}
// close table>
echo "</table>";
?>
</div>
<div id="content_2" class="content">
<!--Cashier-->
<?php echo $message;
echo $message1;
?>
<form name="form1" onsubmit="return validateForm(validation_script.js);" action="admin_cashier.php" method="post" >
<table width="220" height="106" border="0" >
<tr><td align="center"><input name="first_name" type="text" style="width:170px" placeholder="First Name" required="required" id="first_name" /></td></tr>
<tr><td align="center"><input name="last_name" type="text" style="width:170px" placeholder="Last Name" required="required" id="last_name" /></td></tr>
<tr><td align="center"><input name="staff_id" type="text" style="width:170px" placeholder="Staff ID" required="required" id="staff_id"/></td></tr>
<tr><td align="center"><input name="postal_address" type="text" style="width:170px" placeholder="Address" required="required" id="postal_address" /></td></tr>
<tr><td align="center"><input name="phone" type="text" style="width:170px"placeholder="Phone" required="required" id="phone" /></td></tr>
<tr><td align="center"><input name="email" type="email" style="width:170px" placeholder="Email" required="required" id="email" /></td></tr>
<tr><td align="center"><input name="username" type="text" style="width:170px" placeholder="Username" required="required" id="username" /></td></tr>
<tr><td align="center"><input name="password" type="password" style="width:170px" placeholder="Password" required="required" id="password"/></td></tr>
<tr><td align="right"><input name="submit" type="submit" value="Submit"></td></tr>
</table>
</form>
</div>
</div>
</div>
</div>
<div id="footer" align="Center">Developed by IT$ MINE</div>
</div>
</body>
</html>