線上書籍

Home

[1032]PHP入門

<?php //設定新聞發布密碼 $passwd='12345'; //過濾外面傳來的變數 $op=isset($_POST['op'])?$_POST['op']:""; $password=isset($_POST['password'])?$_POST['password']:""; $news_title=isset($_POST['news_title'])?$_POST['news_title']:""; $news_content=isset($_POST['news_content'])?$_POST['news_content']:""; //接收使用者輸入密碼,失敗轉回發布頁 if($op=="save" && (empty($password) || $password!=$passwd)){ setcookie('news_title',$news_title); setcookie('news_content',$news_content); header("location:post.php?op=passwd_error"); }else{ // nl2br()將換行符號轉換為<br>標籤 $news_content=nl2br($news_content); } //載入小強樣板引擎 include_once('tbs_class.php'); $TBS =new clsTinyButStrong ; //套用到 index_tpl.html 樣板 $TBS->LoadTemplate('index_tpl.html',False) ; $TBS->Show() ; ?>