Học php, mysql và javascript - p 46

Example 20-12. You need to login to view this page"); $user = $_SESSION['user']; if (isset($_GET['view'])) $view = sanitizeString($_GET['view']); else $view = $user; if (isset($_POST['text'])) { $text = sanitizeString($_POST['text']); if ($text != "") { $pm = substr(sanitizeString($_POST['pm']),0,1); $time = time(); queryMysql("INSERT INTO rnmessages VALUES(NULL, '$user', '$view', '$pm', $time, '$text')"); } } if ($view != "") { if ($view == { $name1 = $name2 = } else { $name1 = $name2 = } $user) "Your"; "Your"; "$view's"; "$view's"; echo "$name1 Messages"; showProfile($view); echo Type here to leave a message: . | Example 20-12. php include_once if isset _SESSION user die br br You need to login to view this page user _SESSION user if isset _GET view view sanitizeString _GET view else view user if isset _POST text text sanitizeString _POST text if text pm substr sanitizeString _POST pm 0 1 time time queryMysql INSERT INTO rnmessages VALUES NULL user view pm time text if view if view user name1 Your name2 Your else name1 a href view view view a s name2 view s echo h3 name1 Messages h3 showProfile view echo _END form method post action view view Type here to leave a message br textarea name text cols 40 rows 3 textarea br Public input type radio name pm value 0 checked checked Private input type radio name pm value 1 input type submit value Post Message form _END if isset _GET erase erase sanitizeString _GET erase queryMysql DELETE FROM rnmessages WHERE id erase AND recip user 431 query SELECT FROM rnmessages WHERE recip view ORDER BY time DESC result queryMysql query num mysql_num_rows result for j 0 j num j row mysql_fetch_row result if row 3 0 row 1 user row z user echo date M jS y g sa row 4 echo a href echo view row 1 row 1 a if row 3 0 echo wrote quot row 5 quot else echo whispered i font color 006600 quot row 5 quot font i if row 2 user echo a href view view echo erase row 0 erase a echo br if num echo li No messages yet li br echo br a href view view Refresh messages a echo a href view view View name2 friends a The final ingredient in our social networking recipe is Example 20-13 the logout page that closes a session and deletes any associated data and cookies. The result of calling up this program can be seen in Figure 20-8 where the user is now asked to click on a link which will take them to the un-logged-in home page and remove the logged-in links from the top of the screen. Of course you could .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.