PHP經典項目案例-(一)部落格管理系統5
本篇實現發表部落格。
八、發表部落格
(1)、介面實現file.php
編輯文章時各個選項使用js實現:UBBCode.js
helpstat = false;basic = false;function AddText(NewCode) {document.all("file").value+=NewCode}function showsize(size) {if (helpstat) {alert("文字大小標記\n設定文字大小.\n可變範圍 1 - 6.\n 1 為最小 6 為最大.\n用法: 這是 "+size+" 文字");} else if (basic) {AddTxt="";AddText(AddTxt);} else { txt=prompt("大小 "+size,"文字"); if (txt!=null) { AddTxt=""+txt;AddText(AddTxt);AddTxt="";AddText(AddTxt);} }}function bold() {if (helpstat) {alert("加粗標記\n使文本加粗.\n用法: 這是加粗的文字");} else if (basic) {AddTxt="";AddText(AddTxt);} else { txt=prompt("文字將被變粗.","請在這裡輸入要加粗的文字!"); if (txt!=null) { AddTxt=""+txt;AddText(AddTxt);AddTxt="";AddText(AddTxt);} }}function italicize() {if (helpstat) {alert("斜體標記\n使文本字型變為斜體.\n用法: 這是斜體字");} else if (basic) {AddTxt="";AddText(AddTxt);} else { txt=prompt("文字將變斜體","請在這裡輸入要傾斜的文字!"); if (txt!=null) { AddTxt=""+txt;AddText(AddTxt);AddTxt="";AddText(AddTxt);} }}function showcolor(color) {if (helpstat) {alert("顏色標記\n設定文本顏色. 任何顏色名都可以被使用.\n用法: 顏色要改變為"+color+"的文字");} else if (basic) {AddTxt="";AddText(AddTxt);} else { txt=prompt("選擇的顏色是: "+color,"請在這裡輸入要改變顏色的文字!");if(txt!=null) {AddTxt=""+txt;AddText(AddTxt); AddTxt="";AddText(AddTxt);} }}function showfont(font) { if (helpstat){alert("字型標記\n給文字設定字型.\n用法: 改變文字字型為"+font+"");} else if (basic) {AddTxt="";AddText(AddTxt);} else { txt=prompt("要設定字型的文字"+font,"請在這裡輸入要改變字型的文字!");if (txt!=null) { AddTxt=""+txt;AddText(AddTxt);AddTxt="";AddText(AddTxt);} } }function underline() { if (helpstat) {alert("底線標記\n給文字加底線.\n用法: 要加底線的文字");} else if (basic) {AddTxt="";AddText(AddTxt);} else { txt=prompt("底線文字.","文字"); if (txt!=null) { AddTxt=""+txt;AddText(AddTxt);AddTxt="";AddText(AddTxt);} }}
(2)後台添加到資料庫實現check_file.php
execute_dml($sql); if($res==1){ echo ""; echo ""; }else{ echo ""; echo ""; }?>