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
111
112
113
114
115
116
|
<?php
session_start();
/*
dbEditor.php
*/
if(!$_SESSION[logedin]){
header('Location: ./BooKa.php');
}
$errorMsg = null; //ERRORMSG!
include "./inc/dbConnect.php";
//manipulation of DB
$newname = $_POST[name];
$newphone = $_POST[phone];
$newmail = $_POST[email];
$newadress = $_POST[adress];
$newStartDate = $_POST[StartDate];
$newEndDate = $_POST[EndDate];
$valid = true; //this will be true untill it is changed.
include "./inc/formif.php";//ifs and buts for checking if inputed data is there.
include "./inc/regex.php";//RegEX chexing of dates.
//TODO: figure out why the errorMsg is only set by regex.php ...
if( $valid ){
$db->queryexec("BEGIN;
INSERT INTO bookings(name, StartDate, EndDate, phone, mail, adress) VALUES('{$newname}', '{$newStartDate}', '{$newEndDate}', '{$newphone}', '{$newmail}', '{$newadress}');
COMMIT") or die("could not insert in to table");
sleep(.5);
header('Location: ./dbEditor.php');
}
//end of DB manipulation.
include "./inc/head.php";
?>
<div class="head"><img src="./img/Logo.png" alt="BooKa´s logo" /></div>
<div class="menu2">
<h2> You are logedin <a href="logout.php"> [logout] </a><a href="BooKa.php"> [Return] </a> </h2>
<hr />
<?php
if($errorMsg!=null){
echo " <p class='warning'>".$errorMsg."</p> <!-- this paragraph is created by the php script -->";
}
?>
<form action="dbEditor.php" method="post">
<div class="lefta">
<label for="name" <?php echo $nameunset ?>>Name</label> <input type="text" name="name" <?php echo $nameunset ?> /> <br />
<label for="phone" <?php echo $phoneunset ?>>Phone number</label> <input type="text" name="phone" id="phone" <?php echo $phoneunset ?> /><br />
<label for="email" <?php echo $emailunset ?>>e-mail address</label> <input type="text" name="email" id="email" <?php echo $emailunset ?> /><br />
</div>
<div class="righta">
<label for="adress" <?php echo $adressunset ?> >adress</label> <input type="text" name="adress" id="adress" <?php echo $adressunset ?> /> <br />
<label for="StartDate" <?php echo $StartDateunset ?>>Start Date </label> <input type="text" name="StartDate" id="StartDate" <?php echo $StartDateunset ?> /><br />
<label for="EndDate" <?php echo $EndDateunset ?> >End Date</label> <input type="text" name="EndDate" id="EndDate" <?php echo $EndDateunset ?> /> <br />
</div>
<input type="hidden" name="fromadd" value="true" />
<p><input type="submit" value="add" name="add" class="add" /></p>
</form>
<h2> current DB structure. </h2>
<table> <!-- tabell -->
<tr> <!-- row one -->
<td> id </td>
<td> Name </td>
<td> Start Date </td>
<td> End Date </td>
<td> Phone Number </td>
<td> E-mail </td>
<td> Adress </td>
<td> remove </td>
</tr> <!-- end of row one -->
<?php
$result = $db->query("SELECT * FROM bookings") or die("could not do query!");
foreach($result as $row){
?>
<tr> <!-- Row two and up -->
<td> <?php echo $row[id]?> </td>
<td> <?php echo $row[name]?> </td>
<td> <?php echo $row[StartDate]?> </td>
<td> <?php echo $row[EndDate]?> </td>
<td> <?php echo $row[phone]?> </td>
<td> <?php echo $row[mail]?> </td>
<td> <?php echo $row[adress]?> </td>
<td>
<form action="removeFromDB.php" method="post">
<p>
<input type="submit" value="remove" />
<input type="hidden" value="<? echo $row[id]?>" name="id"/>
</p>
</form>
</td>
</tr> <!-- end of row two and up -->
<?php
}
?>
</table>
</div>
<?php
include "./inc/foot.php"
?>
|