前言
反思了最近写的一些东西,有些小感触
对于学过java或C++的coder来说,
老说语法也没啥意思,OOP,异常之类的技术
不是看看简单的实例代码就能会的,
不懂的可以google喽~
START!
暂时不在blog上写死知识了,还是暂时先在blog上写blog吧~
计划是Practical PHP and MySQL书中第一个实例.
需要一个良好的存储模型数据库中需要建立的3个表
用相关的id的进行各个数据之间的匹配
blog的大体逻辑框架 config.php功能 : 提供常量,一般是一些简单的配置.
内容 :
数据库---[host] [username] [password] [dbname]
博客相关---[博客名称] [作者] [主页的根目录]
header.php功能 : 给每个博客页面的初始化工作
内容 :
每个页面的博客顶部标题---html
数据库连接---MySQL
登陆验证---正确登陆后可以进行博客管理---SESSION
footer.php功能 : 在每个页面底部添加作者标志.
内容 : © Matter
index.php功能 : 显示文章 , 查看评论 , 显示以前文章
内容 :
在数据库查询文章---MySQL
显示文章标题和内容---PHP
viewentry.php功能 : 利用锚点,查看评论,并添加评论
内容 :
先验证,获取id号---GET
连接数据库,查找对应ID的文章---MySQL
查找所有评论---MySQL
显示文章,评论---php
提交评论的表单---html
viewcat.php功能 : 分类浏览
内容 :
判断请求的id---php
显示相应ID下所有文章---MySQL
Login.php功能 : 登陆---session
Logout.php功能 : 登出---session
addentry.php功能 : 添加文章
内容 :
验证用户---session
写分类和文章---html
添加内容到数据库
updateentry.php功能 : 修改文章
内容 :
验证
数据库的UPDATE命令
编码小收获
1.date()时间格式
date()符号 | 日期 |
D | Sat |
D j | Sat 12 |
D jS | Sat 12th |
D jS F | Sat 12th May |
D jS F Y | Sat 12th May 2012 |
D jS F Y g | Sat 12th May 2012 3 |
D jS F Y g. | Sat 12th May 2012 3. |
D jS F Y g.i | Sat 12th May 2012 3.06 |
D jS F Y g.iA | Sat 12th May 2012 3.06PM |
2.页面设计的时候,可以用header和footer文件,产生固定的效果
3.SQL语句简单格式 : SELECT(选择)--WHERE(条件)--ORDER BY(排序)--DESC(倒序)--LIMIT(限制)
4.用config.php文件保存一些配置信息常量
5.对$_GET和$_POST超级全局变量的使用概览
6.用手过了一遍数据库和网页的编程实践
小感想
这是我的第一个PHP+MySQL的小程序 , 做这个的动机是学习PHP时自以为语法到位了 , 想试试手 . 但遇到了不少困难 .
好的方面 了解了部署一个服务器上的BLOG的流程 , 和原理 .
对PHP在编程中的角色有了一定的理解
使用MySQL和页面互动
了解了锚点,session等以前只是听说过的内容
坏的方面 跟书编码 , 整体感不够(在博客里总结一遍,算是清晰一点吧).
HTML布局和CSS样式掌握的不好 , 这两方面导致我的页面总是莫名其妙的乱了 .
还有SQL语言掌握的不太好 , 只会很"质朴"的操作,没掌握的感觉很明显

To protect the application from session-related XSS attacks, the following measures are required: 1. Set the HttpOnly and Secure flags to protect the session cookies. 2. Export codes for all user inputs. 3. Implement content security policy (CSP) to limit script sources. Through these policies, session-related XSS attacks can be effectively protected and user data can be ensured.

Methods to optimize PHP session performance include: 1. Delay session start, 2. Use database to store sessions, 3. Compress session data, 4. Manage session life cycle, and 5. Implement session sharing. These strategies can significantly improve the efficiency of applications in high concurrency environments.

Thesession.gc_maxlifetimesettinginPHPdeterminesthelifespanofsessiondata,setinseconds.1)It'sconfiguredinphp.iniorviaini_set().2)Abalanceisneededtoavoidperformanceissuesandunexpectedlogouts.3)PHP'sgarbagecollectionisprobabilistic,influencedbygc_probabi

In PHP, you can use the session_name() function to configure the session name. The specific steps are as follows: 1. Use the session_name() function to set the session name, such as session_name("my_session"). 2. After setting the session name, call session_start() to start the session. Configuring session names can avoid session data conflicts between multiple applications and enhance security, but pay attention to the uniqueness, security, length and setting timing of session names.

The session ID should be regenerated regularly at login, before sensitive operations, and every 30 minutes. 1. Regenerate the session ID when logging in to prevent session fixed attacks. 2. Regenerate before sensitive operations to improve safety. 3. Regular regeneration reduces long-term utilization risks, but the user experience needs to be weighed.

Setting session cookie parameters in PHP can be achieved through the session_set_cookie_params() function. 1) Use this function to set parameters, such as expiration time, path, domain name, security flag, etc.; 2) Call session_start() to make the parameters take effect; 3) Dynamically adjust parameters according to needs, such as user login status; 4) Pay attention to setting secure and httponly flags to improve security.

The main purpose of using sessions in PHP is to maintain the status of the user between different pages. 1) The session is started through the session_start() function, creating a unique session ID and storing it in the user cookie. 2) Session data is saved on the server, allowing data to be passed between different requests, such as login status and shopping cart content.

How to share a session between subdomains? Implemented by setting session cookies for common domain names. 1. Set the domain of the session cookie to .example.com on the server side. 2. Choose the appropriate session storage method, such as memory, database or distributed cache. 3. Pass the session ID through cookies, and the server retrieves and updates the session data based on the ID.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Atom editor mac version download
The most popular open source editor

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.