Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to create a blog project

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "how to create a blog project", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to create a blog project" this article.

First, create a project

1) switch to the project directory (I put all the projects under the code folder)

Cd code

2) create a project (project name is blog)

Composer create-project laravel/laravel blog-prefer-dist refers to priority installation of compressed version

Second, the assignment route and the reference of CAPTCHA

1) assign a route first (each reference address must be assigned to each route)

After the creation is successful, see if you can successfully access the

2) reference a third-party library (under the recource folder, org represents)

3) load class require_once'.. / resources/org/code/Code.class.php' in controller

Session_start (); the laravel framework itself encapsulates session. Native session may be used when referencing extension classes, and the entry file index.php is opened.

Require_once'.. / resources/org/code/Code.class.php'; / / include the class first, and the actual path will be modified according to the actual situation. $code = new Code (); / / instantiate an object $code- > doimg (); $_ SESSION ['code'] = $code- > getCode (); / / Save the CAPTCHA to SESSION

Picture call: using routed access method

{{url ('')}}

It is possible that the CAPTCHA is not clear:

This is when we add a click event and create a new verification code alt= "'onclick=this.src=' {{' home/code'}}'" every time we click on it.

Some browsers will think that the address has not changed, so the verification code remains the same.

Alt= "'onclick=this.src=' {{' home/code'}}?'- Math.random ()"

Third, login form to submit CRFS authentication and CAPTCHA judgment

1) Note that when the form is submitted, the submit button must be in

2) the error is written {{csrf_field ()}} in the CRFS authentication problem of the laravel framework.

3) name in the input tag is the value to be passed to the background

4) use Input::all () to take the value passed from the foreground, which is equivalent to is_post, and use back to return to the previous page with to store the information in session.

If ($input = Input::all ()) {$code = new\ Code; / / instantiate an object $_ code = $code- > getCode (); / / get its own verification code if ($input ['code']! = $_ code) {return back ()-> with (' msg',' CAPTCHA error!') ;} else {dd;}} else {return view ('home/login');}

5) the page prompt information is judged by session.

@ if (session ('msg')) {{session (' msg')}}

@ endif above is all the content of the article "how to create a blog Project". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report