Toggle main menu visibility
新聞
下載
教材
影音
討論
其他選單
好站連結
行事曆
電子相簿
常見問題
萬用表單
即時留言簿
友站消息
社大學員
:::
登入
登入
帳號
密碼
登入
重整畫面
:::
所有書籍
「[1032]PHP入門」目錄
MarkDown
7. 置頂、計數器與 join
1. PHP開發環境與表單
1-1 post.php
1-2 index.php
2. 邏輯判斷及樣板引擎
2-1 index.php
2-2 post.php
2-3 index_tpl.html
3. MySQL的資料存取
3-1 index.php
3-2 post.php
3-3 post_tpl.html
3-4 eznews.sql
4. PHP函數與引入
4-1 post.php
4-2 index.php
4-3 list_tpl.html
4-4 function.php
5. 編輯與刪除資料
5-1 index.php
5-2 list_tpl.html
5-3 post.php
5-4 config.php
5-5 function.php
5-6 post_tpl.html
6. BootStrap各式應用
6-1 post.php
6-2 list_tpl.html
6-3 post_tpl.html
6-4 index.php
7. 置頂、計數器與 join
7-1 post.php
7-2 post_tpl.html
7-3 index.php
7-4 list_tpl.html
7-5 function.php
7-6 eznews.sql
8. 上傳與分頁
8-1 post.php
8-2 index.php
8-3 config.php
8-4 post_tpl.html
8-5 eznews.sql
9. 身份認證機制
9-1 eznews.sql
9-2 post_tpl.html
9-3 list_tpl.html
9-4 config.php
9-5 index.php
9-6 post.php
7-2 post_tpl.html
\[1032\]PHP入門 ============= ``` ".mysql_error()); $news=mysql_fetch_assoc($result); // foreach ($news as $k => $v) { // $$k=$v; // } $news_title=$news['news_title']; $news_content=$news['news_content']; $ip=$news['ip']; $author=$news['author']; $post_time=$news['post_time']; $next_op="update"; }else{ $news_title=isset($_SESSION['news_title'])?$_SESSION['news_title']:""; $news_content=isset($_SESSION['news_content'])?$_SESSION['news_content']:""; $ip=$_SERVER['REMOTE_ADDR']; $author=isset($_SESSION['author'])?$_SESSION['author']:""; $post_time=isset($_SESSION['post_time'])?$_SESSION['post_time']:date("Y-m-d H:i:s"); $next_op="save"; } $main=<<
正常
置頂
高亮
$news_content
請選擇分類
清除
form; return $main; } //儲存新聞 function save_news($sn=""){ //過濾外面傳來的變數 $op=isset($_POST['op'])?$_POST['op']:""; $password=isset($_POST['password'])?$_POST['password']:""; $news_title=isset($_POST['news_title'])?check_input($_POST['news_title']):""; $news_content=isset($_POST['news_content'])?check_input($_POST['news_content']):""; $author=isset($_POST['author'])?check_input($_POST['author']):""; $ip=isset($_POST['ip'])?check_input($_POST['ip']):""; $post_time=isset($_POST['post_time'])?check_input($_POST['post_time']):""; $status=isset($_POST['status'])?check_input($_POST['status']):""; $cate_title=isset($_POST['cate_title'])?check_input($_POST['cate_title']):""; $cate_sn=isset($_POST['cate_sn'])?intval($_POST['cate_sn']):""; //接收使用者輸入密碼,失敗轉回發布頁 if(empty($password) or $password!=_POST_PASSWD){ // 產生 cookie // setcookie('news_title',$news_title); // setcookie('news_content',$news_content); // 產生 session,以記住剛剛使用者輸入的資料,避免需要重打 $_SESSION['news_title']=$news_title; $_SESSION['news_content']=$news_content; $_SESSION['author']=$author; $_SESSION['status']=$status; $_SESSION['cate_sn']=$cate_sn; //轉回編輯頁面,並用 get 方式,傳遞 $op 以便顯示密碼有誤的訊息 header("location:{$_SERVER['PHP_SELF']}?op=passwd_error"); exit; }else{ // nl2br()將換行符號轉換為
標籤 //$news_content=nl2br($news_content); // 發布正確,剛剛輸入的內容無需在記住,因此清空之。 session_destroy(); } link_db(); //新增分類 if(empty($cate_sn) and !empty($cate_title)){ $sql="insert into eznews_cate (cate_title) values('$cate_title')"; mysql_query($sql) or die($sql."
".mysql_error()); $cate_sn=mysql_insert_id(); }elseif(!empty($cate_sn) and !empty($cate_title)){ //修改分類 $sql="update eznews_cate cate_title='$cate_title' where cate_sn='$cate_sn'"; mysql_query($sql) or die($sql."
".mysql_error()); } //存到資料庫 if($sn){ $sql="update eznews set cate_sn='$cate_sn', news_title='$news_title', news_content='$news_content', ip='$ip', author='$author', post_time='$post_time', status='$status' where sn='$sn'"; }else{ $sql="insert into eznews (cate_sn,news_title, news_content, ip, author, post_time,status) values('$cate_sn','$news_title', '$news_content', '$ip', '$author', '$post_time', '$status')"; } mysql_query($sql) or die($sql."
".mysql_error()); } //替特殊符號加入反斜線 function check_input($value){ if (!get_magic_quotes_gpc()){ $value = addslashes($value); } return $value; } ?> ```
:::
搜尋
search
進階搜尋
QR Code 區塊
快速登入
所有討論區
「PHP全端開發」線上課程討論區
XOOPS使用討論區
一般研習學員
社大學員專用
路過哈啦區
XOOPS佈景設計
XOOPS模組開發
Tad書籍區
即時留言簿
書籍目錄
展開
|
闔起
線上使用者
130
人線上 (
65
人在瀏覽
線上書籍
)
會員: 0
訪客: 130
更多…