-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd.php
More file actions
50 lines (36 loc) · 1.06 KB
/
add.php
File metadata and controls
50 lines (36 loc) · 1.06 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
<?php
include_once("config.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add Script</title>
</head>
<body>
<?php
if( isset($_POST['Submit'])){
$name = mysqli_real_escape_string($mysqli, $_POST['name']);
$age = mysqli_real_escape_string($mysqli, $_POST['age']);
$email = mysqli_real_escape_string($mysqli, $_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 = mysqli_query($mysqli, "INSERT INTO users(name, age, email) VALUES ('$name', '$age', '$email')");
echo "<font color='green'> Data Added Successfully.";
echo "<br/><a href='index.php'> View Result </a>";
}
}
?>
</body>
</html>