5
TODO:need to make a way to add to DB and remove from it.
7
if(!$_SESSION[logedin]){
9
header('Location: ./BooKa.php');
3
13
include "./inc/dbConnect.php";
5
if($_SESSION[Login] != true){
6
header("Location: ./index.php");
16
$newname = $_POST[name];
17
$newphone = $_POST[phone];
18
$newmail = $_POST[email];
19
$newadress = $_POST[adress];
20
$newStartDate = $_POST[StartDate];
21
$newEndDate = $_POST[EndDate];
24
if( $newname != null && $newphone != null && $newmail != null && $newadress != null && $newStartDate != null && $newEndDate != null ){
26
$db->queryexec("BEGIN;
27
INSERT INTO bookings(name, StartDate, EndDate, phone, mail, adress) VALUES('{$newname}', '{$newStartDate}', '{$newEndDate}', '{$newphone}', '{$newmail}', '{$newadress}');
28
COMMIT") or die("could not insert in to table");
31
//end of DB manipulation.
33
include "./inc/formif.php";
9
34
include "./inc/head.php";
13
<form id="dbEdit" method="post" action="./dbEditor.php" >
14
<p>Start date<input type="text" name="startDate" /> End date <input type="text" name="endDate" /> <br />
15
Name <input type="text" name="name" /> phone number <input type="text" name="Phone" /> e-mail adress <input type="text" name="adress" /> <br />
16
<input type="submit" value="add to DB" /></p>
21
if($_POST[startDate] != null && $_POST[endDate] != null && $_POST[name] != null){
23
$NName = "'".$_POST[name]."'";
26
INSERT INTO booking (name, email, StartDate, EndDate) VALUES({$NName},{$_POST[adress]},{$_POST[startdate]},{$_POST[endDate]});
29
echo "Values has been addet to DB.<br /> \n";
33
echo "You need to enter: Start Date, End Date and Name! <br /> \n";
37
$result=$db->query("SELECT * FROM booking");
39
echo "current database structure:<br /> \n";
40
while($result->valid()){
42
$row = $result->current();
44
echo "<div id=#DB>" . $row . "</div>";
50
include "./inc/foot.php";
37
<div class="head"><img src="./img/Logo.png" alt="BooKa´s logo" /></div>
40
<h2> You are logedin <a href="logout.php"> [logout] </a><a href=BooKa.php> [Return] </a> </h2>
42
<form action="dbEditor.php" method="post">
44
<label for="name" <? echo $nameunset ?>>Name</label> <input type="text" name="name" <? echo $nameunset ?> /> <br />
45
<label for="phone"<? echo $phoneunset ?>>Phone number</label> <input type="text" name="phone" id="phone" <? echo $phoneunset ?> /><br />
46
<label for="email" <? echo $emailunset ?>>e-mail address</label> <input type="text" name="email" id="email" <? echo $emailunset ?> /><br />
49
<label for="adress" <? echo $adressunset ?> >adress</label> <input type="text" name="adress" id="adress" <? echo $adressunset ?> /> <br />
50
<label for="StartDate"<? echo $StartDateunset ?>>Start Date </label> <input type="text" name="StartDate" id="StartDate" <? echo $StartDateunset ?> /><br />
51
<label for="EndDate" <? echo $EndDateunset ?> >End Date</label> <input type="text" name="EndDate" id="EndDate" <? echo $EndDateunset ?> /> <br />
53
<input type="hidden" name="fromadd" value="true" />
54
<p><input type="submit" value="add" name="add" class="add" /></p>
57
<h2> current DB structure (Remove buton does not work.) </h2>
59
<table> <!-- muckup tabell -->
65
<td> Phone Number </td>
69
</tr> <!-- end of row one -->
72
$result = $db->query("SELECT * FROM bookings") or die("could not do query!");
73
foreach($result as $row){
75
<tr> <!-- Row two and up -->
76
<td> <? echo $row[id]?> </td>
77
<td> <? echo $row[name]?> </td>
78
<td> <? echo $row[StartDate]?> </td>
79
<td> <? echo $row[EndDate]?> </td>
80
<td> <? echo $row[phone]?> </td>
81
<td> <? echo $row[mail]?> </td>
82
<td> <? echo $row[adress]?> </td>
84
<form action="removeFromDB.php" method="post">
86
<input type="submit" value="remove" />
87
<input type="hidden" value="<? echo $row[id]?>" name="id"/>
91
</tr> <!-- end of row two and up -->
102
include "./inc/foot.php"