-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpharm-customer.php
150 lines (121 loc) · 3.6 KB
/
pharm-customer.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
<!DOCTYPE html>
<html>
<link rel="stylesheet" type="text/css" href="table1.css">
<link rel="stylesheet" type="text/css" href="nav2.css">
<link rel="stylesheet" type="text/css" href="form4.css">
<style>
body {font-family:Arial;}
</style>
<body>
<div class="sidenav">
<h2 style="font-family:Arial; color:white; text-align:center;"> Pharmacy Management System </h2>
<a href="pharmmainpage.php">Dashboard</a>
<a href="pharm-inventory.php">View Inventory</a>
<a href="pharm-pos1.php">Add New Sale</a>
<button class="dropdown-btn">Customers
<i class="down"></i>
</button>
<div class="dropdown-container">
<a href="pharm-customer.php">Add New Customer</a>
<a href="pharm-customer-view.php">View Customers</a>
</div>
</div>
<?php
include "config.php";
session_start();
$sql="SELECT E_FNAME from EMPLOYEE WHERE E_ID='$_SESSION[user]'";
$result=$conn->query($sql);
$row=$result->fetch_row();
$ename=$row[0];
?>
<div class="topnav">
<a href="logout1.php">Logout(signed in as <?php echo $ename; ?>)</a>
</div>
<center>
<div class="head">
<h2> ADD CUSTOMER DETAILS</h2>
</div>
</center>
<br><br><br><br><br><br><br><br>
<div class="one">
<div class="row">
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<div class="column">
<p>
<label for="cid">Customer ID:</label><br>
<input type="number" name="cid">
</p>
<p>
<label for="cfname">First Name:</label><br>
<input type="text" name="cfname">
</p>
<p>
<label for="clname">Last Name:</label><br>
<input type="text" name="clname">
</p>
<p>
<label for="age">Age:</label><br>
<input type="number" name="age">
</p>
<p>
<label for="sex">Sex: </label><br>
<select id="sex" name="sex">
<option value="selected">Select</option>
<option>Female</option>
<option>Male</option>
<option>Others</option>
</select>
</p>
</div>
<div class="column">
<p>
<label for="phno">Phone Number: </label><br>
<input type="number" name="phno">
</p>
<p>
<label for="emid">Email ID:</label><br>
<input type="text" name="emid">
</p>
</div>
<input type="submit" name="add" value="Add Customer">
</form>
<br>
<?php
include "config.php";
if(isset($_POST['add']))
{
$id = mysqli_real_escape_string($conn, $_REQUEST['cid']);
$fname = mysqli_real_escape_string($conn, $_REQUEST['cfname']);
$lname = mysqli_real_escape_string($conn, $_REQUEST['clname']);
$age = mysqli_real_escape_string($conn, $_REQUEST['age']);
$sex = mysqli_real_escape_string($conn, $_REQUEST['sex']);
$phno = mysqli_real_escape_string($conn, $_REQUEST['phno']);
$mail = mysqli_real_escape_string($conn, $_REQUEST['emid']);
$sql = "INSERT INTO customer VALUES ($id, '$fname', '$lname',$age,'$sex',$phno, '$mail')";
if(mysqli_query($conn, $sql)){
echo "<p style='font-size:8;'>Customer successfully added!</p>";
} else{
echo "<p style='font-size:8; color:red;'>Error! Check details.</p>";
}
}
$conn->close();
?>
</div>
</div>
</body>
<script>
var dropdown = document.getElementsByClassName("dropdown-btn");
var i;
for (i = 0; i < dropdown.length; i++) {
dropdown[i].addEventListener("click", function() {
this.classList.toggle("active");
var dropdownContent = this.nextElementSibling;
if (dropdownContent.style.display === "block") {
dropdownContent.style.display = "none";
} else {
dropdownContent.style.display = "block";
}
});
}
</script>
</html>