baza.php
----------
Kod
<?php
function connection() {
global $conn;
$conn =mysql_connect("host", "user", "haslo");
if (!$conn || !mysql_select_db("nazwa_bazy",$conn)) {
return 0;
} else {
return $conn;
}
}
function sql($query) {
if(!($conn = connection())) {
return 0;
}
else {
$result = mysql_query($query,$conn);
if(!$result) {
printf("<div style=\"font: 8pt Verdana, Tahoma, Arial, Helvetica, sans-serif;\">");
printf("<hr color=\"red\">ERROR %s :",mysql_errno());
printf("[%s]",mysql_error());
printf("<a href=\"mailto:\?subject=EVRY ERROR NR %s : %s\"> Wyslij informacje do administratora.</a>",mysql_errno(),$query);
printf("<hr color=\"red\"></div>");
}
else {
return $result;
}
}
}
?>
function connection() {
global $conn;
$conn =mysql_connect("host", "user", "haslo");
if (!$conn || !mysql_select_db("nazwa_bazy",$conn)) {
return 0;
} else {
return $conn;
}
}
function sql($query) {
if(!($conn = connection())) {
return 0;
}
else {
$result = mysql_query($query,$conn);
if(!$result) {
printf("<div style=\"font: 8pt Verdana, Tahoma, Arial, Helvetica, sans-serif;\">");
printf("<hr color=\"red\">ERROR %s :",mysql_errno());
printf("[%s]",mysql_error());
printf("<a href=\"mailto:\?subject=EVRY ERROR NR %s : %s\"> Wyslij informacje do administratora.</a>",mysql_errno(),$query);
printf("<hr color=\"red\"></div>");
}
else {
return $result;
}
}
}
?>
post.php
----------
Kod
<form method="POST" action="dopisz.php">
Imie: <input type="text" name="imie" size="15"><br>
Nazwisko: <input type="text" name="nazwisko" size="20"><br>
Telefon: <input type="text" name="telefon" size="12"><br>
Ilosc: <input type="text" name="ilosc" size="1"><br>
Seans: <input type="text" name="seans" size="4"><br>
<input type="submit" value="Dodaj" name="B1"><input type="reset" value="Wyczysc" name="B2"></p>
</form>
Imie: <input type="text" name="imie" size="15"><br>
Nazwisko: <input type="text" name="nazwisko" size="20"><br>
Telefon: <input type="text" name="telefon" size="12"><br>
Ilosc: <input type="text" name="ilosc" size="1"><br>
Seans: <input type="text" name="seans" size="4"><br>
<input type="submit" value="Dodaj" name="B1"><input type="reset" value="Wyczysc" name="B2"></p>
</form>
dopisz.php
-----------
Kod
<?
include("baza.php");
$sql = sprintf('INSERT INTO `bilety` ( `id` , `imie` , `nazwisko` , `telefon` , `ilosc` , `seans` , `miejsca` ) '
. ' VALUES ( \'\', \'%s\', \'%s\' , \'%s\' , \'%s\' , \'%s\' , \'%s\' ); ', $_POST[imie],$_POST[nazwisko],$_POST[telefon],$_POST[ilosc],$_POST[seans],$_POST[miejsca]);
echo $sql;
sql($sql);
?>
include("baza.php");
$sql = sprintf('INSERT INTO `bilety` ( `id` , `imie` , `nazwisko` , `telefon` , `ilosc` , `seans` , `miejsca` ) '
. ' VALUES ( \'\', \'%s\', \'%s\' , \'%s\' , \'%s\' , \'%s\' , \'%s\' ); ', $_POST[imie],$_POST[nazwisko],$_POST[telefon],$_POST[ilosc],$_POST[seans],$_POST[miejsca]);
echo $sql;
sql($sql);
?>
pokaz.php
------------
Kod
<table border=1 colspan=0 rowspan="2" cellpadding="5" cellspacing="0" >
<tr>
<td><b>ID</b></td><td><b>IMIE</b></td><td><b>NAZWISKO</b></td><td><b>TELEFON</b></td><td><b>ILOSC</b></td><td><b>SEANS</b></td></tr>
<?php
include("baza.php");
$query = "SELECT * FROM bilety;";
$result = sql($query);
while ($row = mysql_fetch_array($result)) {
echo "<tr><td>".$row[id]."</td><td>". $row[imie]."</td><td>".$row[nazwisko]."</td><td>".$row[telefon]."</td><td>".$row[ilosc]."</td><td>".$row[seans]."</td></tr>";
}
print_r ($row);
?>
</table>
<tr>
<td><b>ID</b></td><td><b>IMIE</b></td><td><b>NAZWISKO</b></td><td><b>TELEFON</b></td><td><b>ILOSC</b></td><td><b>SEANS</b></td></tr>
<?php
include("baza.php");
$query = "SELECT * FROM bilety;";
$result = sql($query);
while ($row = mysql_fetch_array($result)) {
echo "<tr><td>".$row[id]."</td><td>". $row[imie]."</td><td>".$row[nazwisko]."</td><td>".$row[telefon]."</td><td>".$row[ilosc]."</td><td>".$row[seans]."</td></tr>";
}
print_r ($row);
?>
</table>
i teraz sedno sprawy, jak napisac plik admin.php ktory:
- wyswietli wszystkie wpisy
- pozwoli je modyfikowac
- pozwoli je kasowac
i po drugie jak zrobic aby skrypt po wpisaniu danych do formularza pokazywal dane wpisane do niego i pytal czy sa prawidlowo jesli tak to wpisywal je do bazy a jesli nie to pozwalal na ich modyfikacje i aby wysylal na maila potwierdzenie rezerwacji.
prosze o propozycje co mozna dodac do rezerwacji biletow w kinie (bo do tego sa te skrypty.
Prosze o szybka odpowiedz, mozliwe ze komus jeszcze sie to przyda (bo moze byc to wykorzystane jako ksiega gosci.
Wiem ze znacie sie na php i bedziecie potrafili pomoc bo ja juz sie zamotalem z lekka i nie bardzo wiem co mam teraz zrobic, prosze o gotowe kody.
Dzieki wielkie z gory.