-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd.php
39 lines (32 loc) · 1012 Bytes
/
add.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
<html>
<head>
<title>Add Data</title>
</head>
<body>
<?php
include_once("db.php");
if(isset($_POST['Submit'])) {
$id = $_POST['id'];
$name = $_POST['name'];
$age = $_POST['age'];
$email = $_POST['email'];
if(empty($name) || empty($age) || empty($email)) {
if(empty($name)) {
echo "<font color='red'>Name field is empty.</font><br/>";
}
if(empty($age)) {
echo "<font color='red'>Age field is empty.</font><br/>";
}
if(empty($email)) {
echo "<font color='red'>Email field is empty.</font><br/>";
}
echo "<br/><a href='javascript:self.history.back();'>Go Back</a>";
} else {
$result = pg_query("INSERT INTO users(id,name,age,email) VALUES('$id','$name','$age','$email')");
echo "<font color='green'>Data added successfully.";
echo "<br/><a href='users.php'>View Result</a>";
}
}
?>
</body>
</html>