-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreatebackend.php
67 lines (42 loc) · 1.57 KB
/
createbackend.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
54
55
56
57
58
59
60
61
62
63
64
65
<?php
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
session_start();
$cfname = $_SESSION['cfname'];
$costlname = $_SESSION['costlname'];
$costid = $_SESSION['costid'];
$conn = new mysqli("sql1.njit.edu", "mp973", "Laptop2001.", "mp973");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$result = mysqli_query($conn, "SELECT * FROM CostumerRecord;");
$count = mysqli_num_rows($result);
$x = 0;
while($row = mysqli_fetch_assoc($result)){
if($row['CID']== $costid){
echo '<script type="text/javascript">';
echo ' alert("Costumer already exists.")'; //not showing an alert box.
echo '</script>';
header('refresh:0.1; url= createaccount.php');
//$sql = "DELETE FROM `CostumerOrders` WHERE OCostumerID = $ccid;";
}else{
$x += 1;
continue;
}
}
if($x == $count){
$sql = "INSERT INTO `CostumerRecord` VALUES ('$cfname', '$costlname', $costid);";
echo '<script type="text/javascript">';
echo ' alert("Costumer Account Created.")'; //not showing an alert box.
echo '</script>';
header('refresh:0.1; url= createaccount.php');
//redirect('returnorder.php');
}
if ($conn->query($sql) === TRUE) {
//echo "New record created successfully";
} else {
//echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>