search
HomeBackend DevelopmentPHP TutorialPHP经典项目案例-(一)博客管理系统5

本篇实现发表博客。

八、发表博客

(1)、界面实现file.php

<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> 

(2)后台添加到数据库实现check_file.php

<?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>";    }?>


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How to make PHP applications fasterHow to make PHP applications fasterMay 12, 2025 am 12:12 AM

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

PHP Performance Optimization Checklist: Improve Speed NowPHP Performance Optimization Checklist: Improve Speed NowMay 12, 2025 am 12:07 AM

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

PHP Dependency Injection: Improve Code TestabilityPHP Dependency Injection: Improve Code TestabilityMay 12, 2025 am 12:03 AM

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

PHP Performance Optimization: Database Query OptimizationPHP Performance Optimization: Database Query OptimizationMay 12, 2025 am 12:02 AM

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi

Simple Guide: Sending Email with PHP ScriptSimple Guide: Sending Email with PHP ScriptMay 12, 2025 am 12:02 AM

PHPisusedforsendingemailsduetoitsbuilt-inmail()functionandsupportivelibrarieslikePHPMailerandSwiftMailer.1)Usethemail()functionforbasicemails,butithaslimitations.2)EmployPHPMailerforadvancedfeatureslikeHTMLemailsandattachments.3)Improvedeliverability

PHP Performance: Identifying and Fixing BottlenecksPHP Performance: Identifying and Fixing BottlenecksMay 11, 2025 am 12:13 AM

PHP performance bottlenecks can be solved through the following steps: 1) Use Xdebug or Blackfire for performance analysis to find out the problem; 2) Optimize database queries and use caches, such as APCu; 3) Use efficient functions such as array_filter to optimize array operations; 4) Configure OPcache for bytecode cache; 5) Optimize the front-end, such as reducing HTTP requests and optimizing pictures; 6) Continuously monitor and optimize performance. Through these methods, the performance of PHP applications can be significantly improved.

Dependency Injection for PHP: a quick summaryDependency Injection for PHP: a quick summaryMay 11, 2025 am 12:09 AM

DependencyInjection(DI)inPHPisadesignpatternthatmanagesandreducesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itallowspassingdependencieslikedatabaseconnectionstoclassesasparameters,facilitatingeasiertestingandscalability.

Increase PHP Performance: Caching Strategies & TechniquesIncrease PHP Performance: Caching Strategies & TechniquesMay 11, 2025 am 12:08 AM

CachingimprovesPHPperformancebystoringresultsofcomputationsorqueriesforquickretrieval,reducingserverloadandenhancingresponsetimes.Effectivestrategiesinclude:1)Opcodecaching,whichstorescompiledPHPscriptsinmemorytoskipcompilation;2)DatacachingusingMemc

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software