450 likes | 786 Views
PHP i MySQL. Programy. PHP Triad 2.2.1 - 13.5MB – Freeware http://httpd.apache.org/ MySQL-Front – 1MB - Freeware ftp://ftp.home.pl/pub/windows/mysql Macromedia HomeSite 5.5 – 15MB – Trial http://www.macromedia.com Macromedia Dreamweaver 2004 MX – 80MB – Trial http://www.macromedia.com
E N D
Programy • PHP Triad 2.2.1 - 13.5MB – Freewarehttp://httpd.apache.org/ • MySQL-Front – 1MB - Freeware ftp://ftp.home.pl/pub/windows/mysql • Macromedia HomeSite 5.5 – 15MB – Trialhttp://www.macromedia.com • Macromedia Dreamweaver 2004 MX – 80MB – Trialhttp://www.macromedia.com • Pomoc do programów Trial’owychhttp://www.crackspider.net
PHP triad 2.2.1 • Serwer WWW – Apache • Serwer PHP • Serwer MySQL
PHP i MySQL Przykład budowy internetowego systemu newsów
Tworzenie bazy danych - PHP function create_db() { $db = mysql_pconnect($server, $login, $password); mysql_create_db('newsy'); print '<b>BAZA UTWORZONA</b><br />'; }
Tworzenie tabel - PHP function create_table_logs() { $tab = 'logs'; mysql_select_db('newsy'); $newsy_tab = "create table $tab ( log_id smallint unsigned not null auto_increment primary key, log_date datetime not null default '0000-00-00 00:00:00', log_author_ip varchar(15) not null default '' )"; $zgloszenie = mysql_query($newsy_tab); echo 'tabela <b>'.$tab.'</b> utworzona<br />'; }
Tworzenie rekordów - PHP function create_admin() //admin 123 { mysql_select_db('newsy'); $new_admin = "INSERT INTO users VALUES ('1', '21232f297a57a5a743894a0e4a801fc3', '202cb962ac59075b964b07152d234b70', '2004-04-19 19:49:52')"; $zgloszenie = mysql_query($new_admin); echo 'dodano <b>admina</b><br />'; }
Dodawanie newsa $nick = addslashes($nick); $text = addslashes($text); $question = „insert into newsy (news_date, news_author, news_text, news_auhor_ip) values (now(), '$nick', '$text', '$ip')"; $result = mysql_query($question); print '<br /><b>Zapisano wiadomość</b>';
Wyświetlanie newsów - SQL $show_rec = 50; $question = "select news_id, news_date, news_author, news_text, news_author_ip from newsy order by news_date desc limit 0, $show_rec";
Wyświetlanie newsów – PHP i html <tr><td bgcolor="#dee3e8" align="center" width="25"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">'.$line[0].'</font></td>
Anti-Flood System $show_rec = 1; $question = "select news_id, news_date, news_author, news_text news_author_ip from newsy order by news_date desc limit 0, $show_rec"; $result = mysql_query($question); $line = mysql_fetch_row($result); if ($nick == $line[2] && $text == $line[3]) print '<br /><b>Anti-Flood ALERT</b>';
Wyszukiwanie newsów - html <form action="results.php" method="post"> <table border="1" bgcolor="#dee3e8" bordercolor="#5e7388"> <tr> <td><font face="Verdana, Arial, Helvetica, sans-serif" size="2">szukaj w:</font></td> <td align="right"> <select name="what"> <option value = "news_id"> ID (number) <option value = "news_date" selected> Data (yyyy-mm-dd hh:mm:ss) <option value = "news_author"> Autor (text) <option value = "news_text"> Text (text) </select>
Wyszukiwanie newsów $question = „select news_id, news_date, news_author, news_text from newsy where ".$what." ".$operator." '%".$word."%' order by ".$sort." ".$az."";
Panel Administratora if (MD5($admin_login)==$line[0] && MD5($admin_password)==$line[1])
The endWystępowali:MySQLPHPhtmlInni:PHP Triad 2.2.1MySQL-FrontMacromedia HomeSite 5.5Macromedia Dreamweaver 2004 MX