-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddcustomer.php
More file actions
105 lines (78 loc) · 2.48 KB
/
addcustomer.php
File metadata and controls
105 lines (78 loc) · 2.48 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
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
<!DOCTYPE html>
<html>
<head>
<title>add customer</title>
<link rel="stylesheet" href="styles.css">
<script type="text/javascript" src="js/main.js"> </script>
</head>
<body>
<h1> ADD CUSTOMER</h1>
<?php
session_start();
if(isset($_SESSION['username']))
echo 'Signed In as '.$_SESSION['username'].'<a href="userlog.php?userid='.$_SESSION['userid'].'&type=logout"> Log Out</a>';
else
die ("not logged in, please log in!!!!<br> <a href=\"login.php\">login</a>");
?>
<form name="addcust" action="addcustomer.php" method="post">
customer Name <input type="text" name="Name" value="" required><br>
Mobile Phone <input type="text" name="mobile" required ><br>
vehicle <input type="text" name="vehicle_no" value="" placeholder="example-ka291234" required><br>
E-Mail <input type="email" name="email" placeholder="you@example.com" required><br>
<!-- Is regular?<input type="text" name="isregular" value="" placeholder="yes/no" required><br> -->
<button type="submit" name="Submit">Add customer</button><br><br><br><br>
<?php
echo '<a href="main.php">Go To Home?</a>';
?>
</form>
<?php
require 'dbConnect.php';
$conn = getConnection();
if($conn->connect_error)
{
header("Location: signUp.php?status=&failed" );
}
if($_POST)
{
$Name=$_POST['Name'];
$ph_no=$_POST['mobile'];
$vehicle_no=$_POST['vehicle_no'];
$email=$_POST['email'];
// $isregular=$_POST['isregular'];
$isWritten=false;
$errorcode=-1;
//echo $fName."<br>".$mName."<br>".$lName."<br>".$email."<br>".$password."<br>".$confirmPasss;
if(!empty($Name)&&!empty($ph_no)&&!empty($vehicle_no)&&!empty($email))
{
$stmt = $conn->prepare("INSERT INTO customer (name,contact_no,vehicle_no,email) VALUES (?, ?, ?,?)");
$stmt->bind_param("ssss", $Name, $ph_no, $vehicle_no,$email);
//echo $Name.$ph_no.$vehicle_no.$isregular;
if($stmt->execute())
{
$isWritten=true;
$errorcode=100;
}else {
$isWritten=false;
$errorcode=100;
}
}
else {
echo "No input";
}
}
if($_POST)
{
if($isWritten)
{
echo "<h2 >Customer Added</h2>";
}else {
echo "<h2 class='error'>Something went wrong please try later</h2>";
echo '<a href="main.php">Take me to Home </a>';
}
if($errorcode<0)
{
echo "<h2 >Adding user.... Please Wait </h2>";
}
} ?>
</body>
</html>