Home > Article > Backend Development > PHP经典项目案例-(一)博客管理系统5
本篇实现发表博客。
八、发表博客<tr> <td colspan="3" valign="baseline" style="BACKGROUND-IMAGE: url( images/bg.jpg); VERTICAL-ALIGN: middle; HEIGHT: 450px; TEXT-ALIGN: center"> <table width="100%" height="100%" cellpadding="0" cellspacing="0"> <tr> <td height="451" align="center" valign="top"> <!-- 发表文章 --> <table width="640" cellpadding="0" cellspacing="0"> <tr> <td width="613" height="223" align="center"> <br><span style="white-space:pre"> </span><table width="500" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <span style="white-space:pre"> </span> <form method="post" action="check_file.php?flag=<?php%20echo%20%24flag;%20if(%24flag)%7Becho%20">"><span style="white-space:pre"> </span> <table width="630" border="1" cellpadding="3" cellspacing="1" bordercolor="#D6E7A5"> <tr> <td class="i_table" colspan="2"> <span class="tableBorder_LTR">添加博客文章</span> </td> </tr> <tr> <td valign="top" align="right" width="14%">博客主题:<br> </td> <td width="86%"><input name="txt_title" type="text" id="txt_title" size="68" value="<?php if($flag){echo $title;}?>"></td> </tr> <tr> <td align="right" width="14%">文字编辑区:</td> <td width="86%"> <img src="images/UBB/B.gif" style="max-width:90%" style="max-width:90%" onclick="bold()" alt="PHP经典项目案例-(一)博客管理系统5" > <img src="images/UBB/I.gif" style="max-width:90%" style="max-width:90%" onclick="italicize()" alt="PHP经典项目案例-(一)博客管理系统5" > <img src="images/UBB/U.gif" style="max-width:90%" style="max-width:90%" onclick="underline()" alt="PHP经典项目案例-(一)博客管理系统5" ><span style="white-space:pre"> </span> 字体 <select name="font" class="wenbenkuang" id="font" onchange="showfont(this.options[this.selectedIndex].value)"> <option value="宋体" selected>宋体</option> <option value="黑体">黑体</option> <option value="隶书">隶书</option> <option value="楷体">楷体</option> </select> 字号<span class="pt9"> <select name="size" class="wenbenkuang" onchange="showsize(this.options[this.selectedIndex].value)"> <option value="1">1</option> <option value="2">2</option> <option value="3" selected>3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> </select> 颜色 <select onchange="showcolor(this.options[this.selectedIndex].value)" name="color" size="1" class="wenbenkuang" id="select"> <option selected>默认颜色</option> <option style="color:#FF0000" value="#FF0000">红色热情</option> <option style="color:#0000FF" value="#0000ff">蓝色开朗</option> <option style="color:#ff00ff" value="#ff00ff">桃色浪漫</option> <option style="color:#009900" value="#009900">绿色青春</option> <option style="color:#009999" value="#009999">青色清爽</option> <option style="color:#990099" value="#990099">紫色拘谨</option> <option style="color:#990000" value="#990000">暗夜兴奋</option> <option style="color:#000099" value="#000099">深蓝忧郁</option> <option style="color:#999900" value="#999900">卡其制服</option> <option style="color:#ff9900" value="#ff9900">镏金岁月</option> <option style="color:#0099ff" value="#0099ff">湖波荡漾</option> <option style="color:#9900ff" value="#9900ff">发亮蓝紫</option> <option style="color:#ff0099" value="#ff0099">爱的暗示</option> <option style="color:#006600" value="#006600">墨绿深沉</option> <option style="color:#999999" value="#999999">烟雨蒙蒙</option> </select></span> </td> </tr> <tr> <td align="right" width="14%">文章内容:</td> <td width="86%"> <span style="white-space:pre"> </span> <div class="file"> <span style="white-space:pre"> </span> <span style="white-space:pre"> </span><textarea name="file" cols="75" rows="20" id="file" style="border:0px;width:520px;"><?php if($flag){echo $content;}?></textarea><span style="white-space:pre"> </span> </div> <span style="white-space:pre"> </span> </td> </tr> <tr align="center"> <td colspan="2"> <input name="btn_tj" type="submit" id="btn_tj" value="提交" onclick="return check();"> <input name="btn_cx" type="reset" id="btn_cx" value="重写"> </td> </tr> </table> <span style="white-space:pre"> </span> </form> <span style="white-space:pre"> </span> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr>
<?php session_start(); require_once 'Conn/SqlHelper.class.php'; $flag = $_GET['flag']; if($flag!=2){ $txt_title = $_POST['txt_title']; $file = $_POST['file']; $author = $_SESSION['username']; $date = date("Y-m-d H:i:s"); } $sqlHelper = new SqlHelper(); if($flag==0){ $sql = "insert into tb_article(title,content,author,now)values('$txt_title','$file','$author','$date')"; } $res = $sqlHelper->execute_dml($sql); if($res==1){ echo "<script>alert('操作成功!');</script>"; echo "<script>window.location.href='myfiles.php';</script>"; }else{ echo "<script>alert('对不起失败了!');</script>"; echo "<script> history.go(-1);</script>"; }?>