/booka/newlayout

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/booka/newlayout

« back to all changes in this revision

Viewing changes to dbEditor.php

  • Committer: Gustav Hartvigsson
  • Date: 2009-12-04 16:51:06 UTC
  • Revision ID: gego@quad-20091204165106-wumf1gzbskkuai0g
merging Neo to trunk. freezing neo branshs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
 
session_start(); 
 
2
session_start();
 
3
/*
 
4
        dbEditor.php
 
5
        TODO:need to make a way to add to DB and remove from it.
 
6
*/
 
7
if(!$_SESSION[logedin]){
 
8
        
 
9
        header('Location: ./BooKa.php');
 
10
        
 
11
}
 
12
 
3
13
include "./inc/dbConnect.php";
4
14
 
5
 
        if($_SESSION[Login] != true){
6
 
        header("Location: ./index.php"); 
7
 
        }
8
 
        
 
15
//manipulation of DB
 
16
$newname = $_POST[name];
 
17
$newphone = $_POST[phone];
 
18
$newmail = $_POST[email];
 
19
$newadress = $_POST[adress];
 
20
$newStartDate = $_POST[StartDate];
 
21
$newEndDate = $_POST[EndDate];
 
22
 
 
23
 
 
24
if( $newname != null && $newphone != null && $newmail != null && $newadress != null && $newStartDate != null && $newEndDate != null ){
 
25
        
 
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");
 
29
        
 
30
}
 
31
//end of DB manipulation.
 
32
 
 
33
include "./inc/formif.php";
9
34
include "./inc/head.php";
10
35
?>
11
36
 
12
 
<div id='dbedit' >
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>
17
 
</form>
18
 
</div>
19
 
 
20
 
<?php
21
 
if($_POST[startDate] != null && $_POST[endDate] != null && $_POST[name] != null){
22
 
        
23
 
        $NName = "'".$_POST[name]."'";
24
 
        
25
 
        $db->query("BEGIN;
26
 
        INSERT INTO booking (name, email, StartDate, EndDate) VALUES({$NName},{$_POST[adress]},{$_POST[startdate]},{$_POST[endDate]});
27
 
        COMMIT;");
28
 
        
29
 
        echo "Values has been addet to DB.<br /> \n";
30
 
        
31
 
} else {
32
 
        
33
 
        echo "You need to enter: Start Date, End Date and Name! <br /> \n";
34
 
        
35
 
}
36
 
 
37
 
$result=$db->query("SELECT * FROM booking");
38
 
                        
39
 
echo "current database structure:<br /> \n";
40
 
while($result->valid()){
41
 
        
42
 
        $row = $result->current();
43
 
                                
44
 
        echo "<div id=#DB>" . $row . "</div>";
45
 
                                
46
 
        $result->next();
47
 
}
48
 
 
49
 
 
50
 
include "./inc/foot.php";
 
37
        <div class="head"><img src="./img/Logo.png" alt="BooKa´s logo" /></div>
 
38
        
 
39
        <div class="menu2">
 
40
                 <h2> You are logedin <a href="logout.php"> [logout] </a><a href=BooKa.php> [Return] </a> </h2>
 
41
                 <hr />
 
42
                 <form action="dbEditor.php" method="post">
 
43
                        <div class="lefta">
 
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 />
 
47
                        </div>
 
48
                        <div class="righta">
 
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 />
 
52
                                </div>
 
53
                        <input type="hidden" name="fromadd" value="true" />
 
54
                        <p><input type="submit" value="add" name="add" class="add" /></p>
 
55
                </form>
 
56
                 
 
57
                <h2> current DB structure (Remove buton does not work.) </h2>
 
58
                 
 
59
                <table> <!-- muckup tabell -->
 
60
                        <tr> <!-- row one -->
 
61
                                <td> id </td>
 
62
                                <td> Name </td>
 
63
                                <td> Start Date </td>
 
64
                                <td> End Date </td>
 
65
                                <td> Phone Number </td>
 
66
                                <td> E-mail </td>
 
67
                                <td> Adress </td>
 
68
                                <td> remove </td>
 
69
                        </tr> <!-- end of row one -->
 
70
                        <?
 
71
                        
 
72
                        $result = $db->query("SELECT * FROM bookings") or die("could not do query!");
 
73
                        foreach($result as $row){
 
74
                        ?>
 
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>
 
83
                                <td>
 
84
                                        <form action="removeFromDB.php" method="post">
 
85
                                                <p>
 
86
                                                        <input type="submit" value="remove" />
 
87
                                                        <input type="hidden" value="<? echo $row[id]?>" name="id"/>
 
88
                                                </p>
 
89
                                        </form>
 
90
                                </td>
 
91
                        </tr> <!-- end of row two and up -->
 
92
                        
 
93
                        <?
 
94
                        }
 
95
                        ?>
 
96
                </table>
 
97
                 
 
98
        </div>
 
99
 
 
100
<?
 
101
 
 
102
include "./inc/foot.php"
51
103
?>
 
104
 
 
105