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
|
<?php
/*
firstrun.php
*/
$username1 = $_POST[userName];
$password1 = $_POST[userPassword];
$password2 = $_POST[userPassword2];
include "./inc/head.php";
if(file_exists("./cfg/lock.lock")){
?>
<p class="warning">This instalation locked, you need to remove ./cfg/lock.lock</p>
<p class="warning">Klick <a href="./BooKa.php"> here </a> to return to the BooKa page.</p>
<?php
//header('Location: ./BooKa.php');
} else {
if($debug){
echo "<p>";
echo "{$username} <br/>";
echo "{$password1} <br/>";
echo "{$password2} <br/>";
echo "</p>";
}
?>
<div class="menu2">
<h1> Welcome to BooKa </h1>
<h2> a Mimimalistic booking software </h2>
<hr />
<p> here you register the abmin account </p>
<form action="firstrun.php" method="post" >
<p>
User name: <input type="text" name="userName" /> <br/>
Password: <input type="password" name="userPassword" /> <br />
Password again: <input type="password" name="userPassword2" /> <br />
<input type="hidden" name="reg" value="true" /> <br/>
<?php
if($_POST[reg]){
if($username1 == null) echo "you need to add a username <br />";
if($password1 == null) echo "you need a password! <br />";
if($password1 != $password2) echo "Passwords deos not match <br />";
}
?>
<input type="submit" name="submitt" />
</p>
</form>
</div>
<?php
}
if($username1 != null && $password1 != null && $password2 == $password1){
include "./inc/dbConnect.php";
$newpassword = md5($password1);
//create users table
//user group 1 is admin, 2 is "normal users"
$db->queryExec("BEGIN;
CREATE TABLE users(id INTEGER PRIMARY KEY, username CHAR(255), password CHAR(255), 'group' INTEGER);
INSERT INTO users (username, password, 'group') VALUES('{$username1}' , '{$newpassword}', '1');
COMMIT;") or die("could not do query");
echo $db->error;
//end of user table creation...
echo "Registration complite";
//This creates the bookins table
$db->queryexec("BEGIN;
CREATE TABLE bookings
(id INTEGER PRIMARY KEY,
name CHAR, phone CHAR,
mail CHAR, adress CHAR,
StartDate DATE, EndDate DATE);
COMMIT;") or die("could not create table:");
echo $db->error;
//end of table creation...
fopen("./cfg/lock.lock", 'w') or die("can't open file");
}
include "./inc/foot.php";
?>
|