-
Notifications
You must be signed in to change notification settings - Fork 13
/
prescription.php
39 lines (28 loc) · 1.37 KB
/
prescription.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
<?php
require "conn.php";
$name=$_POST['username'];
$prescription=$_FILES['prescription'];
$prescription_name=$prescription['name'];
$prescription_type=$prescription['type'];
$prescription_size=$prescription['size'];
$prescription_path=$prescription['tmp_name'];
$folder="prescription upload/";
move_uploaded_file($prescription_path, $folder.$prescription_name);
$today=date("Y-m-d");
$query="SELECT * FROM prescription WHERE name='$name'";
$result=$conn->query($query);
if ($result->num_rows==0) {
$sql="INSERT INTO prescription (name,filename,date) VALUES ('$name','$prescription_name','$today')";
if (mysqli_query($conn, $sql)) {
echo"<script type='text/javascript'>window.alert('Prescription uploaded successfully');window.location='admin dashboard.php';</script>";
} else {
echo"<script type='text/javascript'>window.alert('Something went wrong :(');window.location='admin dashboard.php';</script>";
}
} else {
$sql="UPDATE prescription SET filename='$prescription_name' ";
if (mysqli_query($conn, $sql)) {
echo"<script type='text/javascript'>window.alert('Prescription uploaded successfully');window.location='admin dashboard.php';</script>";
} else {
echo"<script type='text/javascript'>window.alert('Something went wrong :(');window.location='admin dashboard.php';</script>";
}
}