-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.php
51 lines (46 loc) · 1.26 KB
/
database.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
<?php
//mysqli_connect('localhost', 'root', '');
//if (mysqli_connect_error()) {
// echo "connected";
//}
//else {
// echo "failed";
//}
// Create connection
$conn = new mysqli("localhost", "root", "", "hackathon");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Code to insert data
$name = $_POST["username"];
$id = $_POST["id"];
$type = $_POST["type"];
$phn_no = $_POST["mob_no"];
$pwd = $_POST["pwd"];
$sql = "INSERT INTO user (NAME, ID, TYPE, PHN_NO, PWD)
VALUES ('$name', '$id', '$type', '$phn_no', '$pwd')";
//$conn->query($sql);
if ($conn->query($sql) === TRUE) {
// echo "New record created successfully";
echo '<script type="text/javascript">
alert("Account created successfully!!!");</script>';
if ($type === "customer") {
echo '<script type="text/javascript">
window.open("customer.php", "_self");
</script>';
}
else {
echo '<script type="text/javascript">
window.open("seller.php", "_self");
</script>';
}
}
else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
// Code to delete data
//$sql = "DELETE FROM user WHERE NAME='John'";
//$conn->query($sql);
$conn->close();
?>