-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearchdata1.php
138 lines (119 loc) · 2.8 KB
/
searchdata1.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
<html>
<head>
<style type="text/css">
h2{
color:green;
text-align: center;
}
.imgcontainer {
text-align: center;
margin: 24px 0 12px 0;
}
img.avatar {
width: 10%;
border-radius: 70%;
}
.container {
padding: 16px;
}
.submit{
background-color: #4CAF50;
width:25%;
margin-left: 450px;
}
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
border-spacing: 5px;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 15px;
border: 1px solid black;
border-collapse: collapse;
}
tr:nth-child(even) {
background-color: #dddddd;
}
</style>
</head>
<body> <h2>Phone Book</h2>
<div class="imgcontainer">
<img src="/phn.png" alt="Phone " class="avatar" ></div>
</body>
</html>
<?php
if(isset($_POST['search'])){
$db = pg_connect("host=localhost port=5432 dbname=phonebook user=postgres password=root");
/*if(!$db){
echo pg_last_error($db);
}else {
echo "hi";
}*/
$name=$_POST["name"];
$sql =<<<EOF
SELECT * from phonedirectory where name='$_POST[name]' ;
EOF;
$ret = pg_query($db, $sql);
if(!$ret){
echo pg_last_error($db);
exit;
}
echo "<caption><h3>Phone-Book</h3></caption>";
echo "<table>";
echo "<tr>";
echo "<th>PHONE-NUMBER</th>";
echo "<th>NAME</th>";
echo "<th>E-MAIL</th>";
echo "<th>GENDER</th>";
echo "<th>ROLL</th>";
echo "<th>DOB</th>";
echo "<th>COUNTRY</th>";
echo "<th>STATE</th>";
echo "<th>CITY</th>";
echo "</tr>";
while($row = pg_fetch_row($ret)){
echo "<tr>";
echo "<td>".$row[0]."</td>";
echo "<td>".$row[0]."</td>";
echo "<td>".$row[2]."</td>";
echo "<td>".$row[3]."</td>";
echo "<td>".$row[4]."</td>";
echo "<td>".$row[5]."</td>";
echo "<td>".$row[6]."</td>";
echo "<td>".$row[7]."</td>";
echo "<td>".$row[8]."</td>";
}
echo "</tr>";
echo "</table>";
pg_close($db);
}
?>
<html>
<head>
<style type="text/css">
h3{
text-align: center;
color:blue;
}
</style>
</head>
<body>
<form action="dropinfo.php" method="POST">
<h2>To Delete/Drop the Phone-Book data Click on below!!!!</h2>
<button style="margin-left:495px;color:white;background-color:red;width:15%;height:35px" type="submit" name="drop">Drop Data</button>
</form>
</br></br>
<form action="updateinfo.php" method="POST">
<h3>To Update the Phone-Book data Click on below!!!!</h3>
<button style="margin-left:495px;color:white;background-color:green;width:15%;height:35px" type="submit" name="drop">Update Data</button>
</form>
<form action="SearchPage_Lab1.php" >
<button style="width:15%;height:35px;color:white;background-color:black" class="btn" type="submit" name="home">Return Home</button>
</form>
<hr>
<p6>This Website is Developed by <a href="https://www.facebook.com/rahulsinghranjann"><b>Rahul Ranjan</b></p6>
</body>
</html>