-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddsample.php
More file actions
71 lines (70 loc) · 2.24 KB
/
addsample.php
File metadata and controls
71 lines (70 loc) · 2.24 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
<?php
include("auth.php");
if($_SESSION['email']!=NULL)
{
if($_SESSION['type']==NULL)
echo "<div class='form'><h3>Login as a hospital first to insert samples</h3><br/>Click here to <a href='hospitallogin.php'>Login</a></div>";
else
{
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hospital Registration</title>
<link rel="stylesheet" href="css/style.css?2.2" />
</head>
<body>
<?php
require('db.php');
// If form submitted, insert values into the database.
if (isset($_REQUEST['name'])){
$name = stripslashes($_REQUEST['name']); // removes backslashes
$name = mysqli_real_escape_string($con,$name); //escapes special characters in a string
$grp = stripslashes($_REQUEST['grp']);
$grp = mysqli_real_escape_string($con,$grp);
$email=$_SESSION['email'];
$query="SELECT id from hospital WHERE email LIKE '$email'";
$result = mysqli_query($con,$query);
echo(mysqli_error($con));
$row = $result->fetch_assoc();
//echo($row["id"]);
$r=$row["id"];
$query = "INSERT into `samples` (samplename, type, hospitalid) VALUES ('$name', '$grp', '$r')";
$result = mysqli_query($con,$query);
echo(mysqli_error($con));
if($result){
echo "<div class='form'><h3>Your sample is added successfully.</h3><br/>Click here to go to <a href='index.php'>Homepage</a></div>";
}
}else{
?>
<div class="form">
<h1>Sample Registration</h1>
<input type="button" value="Homepage" onclick="window.location.href='index.php'"></input><br /><br />
<form name="registration" action="" method="post">
<input type="text" name="name" placeholder="sample name" required /></br></br>
<a>Blood Group</a>
<select name="grp" >
<option value="A">O+</option>
<option value="A+">A+</option>
<option value="B+">B+</option>
<option value="AB+">AB+</option>
<option value="O-">O-</option>
<option value="A-">A-</option>
<option value="B-">B-</option>
<option value="AB-">AB-</option>
</select>
</br></br>
<input type="submit" name="submit" value="Register" />
</form>
<br /><br />
</div>
<?php }
}
}
else
{
echo "<div class='form'><h3>Login as a hospital first to insert samples</h3><br/>Click here to <a href='hospitallogin.php'>Login</a></div>";
} ?>
</body>
</html>