This repository has been archived by the owner on Aug 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 116
/
instructions.php
110 lines (82 loc) · 3.03 KB
/
instructions.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
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
106
107
108
109
110
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Setup Instructions</title>
<?php require("".dirname(__FILE__)."/bootstrap.php") ?>
</head>
<body>
<!-- Sidebar -->
<div id="wrapper">
<div class="col-md-3">
<?php require("".dirname(__FILE__)."/sidebar.php") ?>
</div>
<!-- /#sidebar-wrapper -->
<!-- Page Content -->
<div id="page-content-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<h1>Setup Instructions</h1>
<p><br>DVWS can be used with a XAMPP setup. XAMPP is a free and open source cross-platform web server solution which mainly consists of an Apache Web Server and MySQL database. </p>
<p>Click on the 'Create / Reset Database' button below to create or reset your database. If the database already exists, it will be cleared and all data will be reset. Incase of any MySQL Access denied error, make necessary changes in the <b>dvws/instructions.php.</b></p>
<form action="<?php $_PHP_SELF ?>" method="post">
<input name="create_db" type="submit" value="Reset Database">
</form>
</body>
</html>
<?php
if (isset( $_POST["create_db"])) {
//connect to database. Make necessary changes to $connect for successful connection
$connect = new mysqli('localhost', 'root', '');
if ($connect->connect_error) {
die("Connection failed<br> " . $conn->connect_error);
}
//delete previous database
$drop_db = "DROP DATABASE dvws";
if ($connect->query($drop_db) === TRUE) {
echo "<br>Database deleted successfully <br>";
} else {
echo "Error deleting database <br> " . $connect->error;
}
//create new database
$create_db = "CREATE DATABASE dvws";
if ($connect->query($create_db) === TRUE) {
echo "<br> Database created successfully ";
} else {
echo "Error creating database <br> " . $connect->error;
}
$connect = new mysqli('localhost', 'root', '','dvws');
$create_tb = "CREATE TABLE users
(
id int,
first_name varchar(15),
last_name varchar(15),
secret varchar(15)
)";
if ($connect->query($create_tb) === TRUE) {
echo "<br> Tables created successfully <br>";
} else {
echo "Error creating tables <br>" . $connect->error;
}
$insert = "INSERT INTO `users` VALUES
('1','Darth','Vader','039498utr'),
('2','Gordon','Brown','fgkjiu4h54'),
('3','Hack','Me','1337'),
('4','Pablo','Picasso','34sdfrsdgf'),
('5','Kylo','Ren','34sdfrsdgf'),
('6','Anakin','Skywaler','343425d33'),
('7','Aaron','Unknown','34434222'),
('8','Bob','Smith','5jhgjdyh3343')";
if ($connect->query($insert) === TRUE) {
echo "Data inserted successfully <br>";
} else {
echo "Error inserting data <br> " . $connect->error;
}
$connect->close();
}
?>