php 2 guest php HTML HEAD TITLE TITLE
- Slides: 54
php 2
guest. php • • <HTML> <HEAD> <TITLE>Гостевая книга</TITLE> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> • </HEAD> • <BODY> • <? require("config. php");
• • • • • function show_form() { ? > <form method="post" action=""> Имя <input type="text" name="name" maxlength="22"> E-mail <input type="text" name="email" maxlength="21"> Сообщение <textarea cols="70" rows="20" name="mess"></textarea> <input type="submit" value="Послать"> <input type="reset" value="Очистить"> </form> <? }
config. php • <? $base = "base. txt";
guest. php • function save_mess() • { • global $name, $email, $mess, $base; • $date = date("d. m. y - H: i: s"); • • • } $text = $name. "^^". $email. "^^". $date. "^^". $mess. "n"; $fp = fopen($base, "a"); fputs($fp, $text); fclose($fp);
guest. php • function show_mess() • { • global $base, $Mess. On. Screen; • • • $file = file($base); $file = array_reverse($file); echo "<table>"; if(sizeof($file) < $Mess. On. Screen) $Mess. On. Screen = sizeof($file); for ($i = 0; $i < $Mess. On. Screen; $i++) { $mess = explode("^^", $file[$i]); ? >
• • • • <tr> <td> <p>Написал: <? echo "<a href='mailto: ". $mess[1]. "'>". $mess[0]. "</a>"; echo " "; echo $mess[2]; ? > </td> <p><? =$mess[3]; ? ></td> </tr> <? } echo "</table></td>"; }
• function check_mess() • { • global $name, $email, $mess; • $mess=trim($mess); • $email=trim($email); • $name=trim($name); • • • $name = htmlspecialchars($name); $email = htmlspecialchars($email); $mess = htmlspecialchars($mess); $mess = str_replace("n", " ", $mess);
• • • function output_err($num) { global $err; ? > <center><h 1>Oшибка!</h 1></center> <p><? =$err[$num]; ? > <? exit(); }
• if (empty($name)) output_err(2); • if (!preg_match("/[0 -9 a-z_]+@[0 -9 a-z_^. ]+. [az]{2, 3}/i", $email)) • { • output_err(1); • } • • if (preg_match("/[^(w)|(x 7 Fx. FF)|(s)]/", $name)) output_err(2); • }
guest. php • function check_for_length() • { • global $mess, $email, $name, $Mess. Length; • • if (strlen($mess)>$Mess. Length) output_err(3); $email=substr($email, 0, 21); $name=substr($name, 0, 22); }
guest. php • function check_mess_for_flud() • { • global $mess, $base; • • • $file=file($base); $file=implode("", $file); $mess=preg_quote($mess); if (eregi($mess, $file)) output_err(4); $mess = stripslashes($mess); }
guest. php • function del_mess_from_file() • { • global $base, $Mess. In. File; • • • $file = file($base); $k = 0; if($Mess. In. File<sizeof($file)) { for($i=sizeof($file)-$Mess. In. File; $i<sizeof($file); $i++) { $Res. File[$k]=$file[$i]; $k++; }
• • $fp=fopen($base, "w"); for($i=0; $i<sizeof($Res. File); $i++) { fputs($fp, $Res. File[$i]); } fclose($fp); } }
config. php • $Mess. In. File = 20;
• function check_mess() • { • global $name, $email, $mess; • $mess=trim($mess); • $email=trim($email); • $name=trim($name); • • $name=htmlspecialchars($name); $email=htmlspecialchars($email); $mess=htmlspecialchars($mess); $mess = str_replace("n", " ", $mess);
• check_for_length(); //добавили • if (empty($name)) output_err(2); • if (!preg_match("/[0 -9 a-z_]+@[0 -9 a-z_^. ]+. [az]{2, 3}/i", $email))output_err(1); • if (preg_match("/[^(w)|(x 7 F-x. FF)|(s)]/", $name)) output_err(2); • check_mess_for_flud(); //добавили • del_mess_from_file(); //добавили • }
• if ($mess) { check_mess(); save_mess(); } show_mess(); show_form(); ? > </BODY> </HTML>
• session_start(); session_register('name', 'birth'); $name = "Вася Пупкин"; $birth = "4 марта";
• session_start(); echo session_name(); session_name("My. Session"); echo session_name();
• class Array_class { var $array = array(); • // Определение свойства function get. Uniq. Sum() { • // Получает сумму уникальных элементов • return array_sum(array_unique($this->array)); } • function get. Sorted. Merge() { • /* Возвращает отсортированный массив из ключей и элементов массива */ • $result = array_merge(array_keys($this->array), array_values($this->array)); sort($result); return $result; } }
• function get. Sizeof. Merge() { • /* возвращает число неповторяющихся элементов массива, полученного get. Sorted. Merge() */ • $merge = $this->get. Sorted. Merge(); • return sizeof(array_unique($merge)); } }
• $my = new Array_class; $my->array = array(1, 2, 6, 1); echo $my->get. Uniq. Sum(); $my = new Advanced_array(4); echo $my->get. Sizeof. Merge();
- Doctype html html head
- Bhtml?title=
- Canvas доска
- 12.html?title=
- Html
- Xmldom
- 12.html?title=
- Html head title body
- Html title head
- Html head title
- Slidetodoc.com
- Html 구구단 테이블
- Str::title
- Fungsi tag br pada html
- пример тега description
- Script html head
- Html body section
- Slidetodoc
- 01.html?title=
- Slidetodoc.com
- Radio php post
- Php echo html
- 7 tones
- What is tonic syllable
- Flooded suction pump
- The head of moving head disk with 100 tracks
- Disk
- Difference between dividing head and indexing head
- Quad innervation
- Parts of the leg
- The attacking firm goes head-to-head with its competitor.
- Head.php?mod=
- Filter_validate
- .php?title=
- Www.facebook.com.php
- Php php://input
- Table html title
- 02.html?title=
- 2018html?title=
- Diseo web
- 02.html?action=
- 02.html?page=
- 01.html?title=
- 2016.html?page=
- 10.html?title=
- Html 음악 넣기
- Es.html?title=
- 12.html?title=
- 12.html?title=
- 02.html?title=
- 12.html?title=
- 11.html?site=
- Html12