-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate.php
53 lines (51 loc) · 2.28 KB
/
create.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
<?php
session_start();
if (!isset($_SESSION['username'])) {
header('location:login.php');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>New customer</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="css/tablee.css">
<link rel="stylesheet" type="text/css" href="css/navbarr.css">
<style>
#button {
text-align: center;
}
#cr:hover {
color: white;
background-color: black;
font-size: 20px;
}
</style>
</head>
<?php
session_start();
include 'config.php';
include 'navbar.php';
echo "<br><form method=\"POST\" id=\"create\">";
echo "<label style=\"font-size:25px;\" for=\"name\">Name:</label><input class=\"form-control\" type=\"text\" id=\"name\" name=\"name\" required><br>";
echo "<label style=\"font-size:25px;\" for=\"email\">E-mail:</label><input class=\"form-control\" type=\"text\" id=\"email\" name=\"email\" form=\"create\" required><br>";
echo "<label style=\"font-size:25px;\" for=\"number\">Phone number:</label><input class=\"form-control\" type=\"text\" id=\"number\" name=\"number\" form=\"create\" required><br>";
echo "<label style=\"font-size:25px;\" for=\"balance\">Deposit amount:</label><input class=\"form-control\" type=\"number\" id=\"balance\" name=\"balance\" form=\"create\" required><br>";
echo "<div id=\"button\"><button class=\"btn btn-primary\" id=\"cr\" name=\"submit\">Create</button></div>";
echo "</form>";
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$number = $_POST['number'];
$balance = $_POST['balance'];
$sql = "INSERT INTO customers (name,email,number,balance) VALUES ('$name','$email','$number','$balance')";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully !";
echo "<script> alert('New user created successfully'); window.location='userslist.php?phno=$number'; </script>";
} else {
echo "Error: " . $sql . " " . mysqli_error($conn);
}
}
?>