-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprgm2.php
More file actions
57 lines (56 loc) · 1.38 KB
/
prgm2.php
File metadata and controls
57 lines (56 loc) · 1.38 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
<html>
<head>
<title>prgm</title>
</head>
<body>
<form method="post" action="">
name <input type="text" name="name"><br />
address line1 <input type="text" name="add1"><br />
address line2 <input type="text" name="add2"><br />
email <input type="text" name="e"><br />
<input type="submit" name="sub" value="insert data"><br />
enter name to search
<input type="text" name="s"><br />
<input type="submit" name="sear" value="search"><br />
</form>
</body>
</html>
<?php
$conn=new mysqli('localhost','root','','webprogramming1');
if(!$conn)
echo "db connection error";
if(isset($_POST['sub']))
{
$n=$_POST['name'];
$a=$_POST['add1'];
$d=$_POST['add2'];
$e=$_POST['e'];
echo "name=$n <br />";
echo "addressline1=$a <br />";
echo "addressline2=$d <br />";
echo "email=$e <br />";
$q1="insert into field values('$n','$a','$d','$e')";
if($conn->query($q1))
echo "row inserted <br />";
else
echo "error";
}
if(isset($_POST['sear']))
{
$s=$_POST['s'];
$q2="select * from field where Name='$s'";
$result=$conn->query($q2);
if($result->num_rows>0)
{
while($row=mysqli_fetch_assoc($result))
{
echo "name=".$row['name']."<br />";
echo "address line 1=".$row['addressline1']."<br />";
echo "address line 2=".$row['addressline2']."<br />";
echo "email=".$row['email']."<br />";
}
}
else
echo "no records";
}
?>