Tool class for adding verification codes
Tool class
framework/tool/captchatool.class.php
All work on CAPTCHA: build, validate
?
Properly manage the use of the background image:
Place in Tool Catalog:
?
?
Show use verification code
Add a controller action
Instantiate the tool class to complete the display verification code function!
app/controller/back/admincontroller.class.php
Captchaaction ()
?
The IMG tag on the form page requests the action
App/view/back/login.html
?
This action is also set to verify login exceptions
app/controller/back/backplatformcontrller.class.php
?
?
Verify the verification code
?
Also add a verification function for verification Code tool
?
A sub-function for login verification
app/controller/back/admincontroller.class.php
Signinaction ();
?
?
Save login Information
Use cookie technology to save certain signs of landing!
Save some information about the current user!
The login ID is not saved.
Typical: Saved administrator ID, processed password!
?
?
Save login Information
After you have verified that the administrator is correct:
app/controller/back/admincontroller.class.php
Signinaction ();
?
Get admin Info First!
In the Administrator table model
?
?
Verify cookie information when logging in
?
app/controller/back/backplatformcontroller.clas.sphp
?
Complete the Checkbycookie of Adminmodel
?
Upgrade model
Working with table names
It_category, It_admin
A real table name consists of two parts: the actual table name = prefix + Logical table name
?
Separate the prefix and the logical table name!
Handling prefixes
?
- Add a prefix configuration entry!
- is the prefix attribute for all models (the underlying model) for that value!
When constructed, it is initialized
Working with logical table names
Add a property for each model that represents the logical table name of the current operation
?
Piecing together real table names
?
In the base model, add a method for piecing together real table names!
?
?
In the execution of the SQL statement, where the table name is used, you can use this method:
?
?
?
?
The common features of the model SQL statements are pieced together!
Delete from current table name where primary key field = ' primary key field value '
3
Delete from It_admin where admin_id=3
?
?
Get the basic structure of the model counterpart table
Field name, with, which field is the primary key can!
Add an attribute to save the current model corresponding table basic structure (field collection)
?
Assign a value to a model object when it is instantiated
Complete GetFields ()
?
?
?
Automatically delete
Using the main value, piece together a SQL to delete records according to the primary key, execute!
?
On the base model:
framework/model.class.php
?
This method can be used when deleting:
Classification Model:
Categorymodel
?
?
Automatic use of primary key query
In the underlying model:
Model.class.php
?
Use it for a moment:
When editing a category, get the current classification information:
?
?
Auto Insert
Insert into table name (Field 1, Field 2, field N) VALUES (value 1, value 2, value N)
$data = Array (
????‘ Field 1 ' = = ' value 1 ',
' Field 2 ' = = ' value 2 ',
' Field 3 ' = = ' value 3 ',
);
An associative array is required at this point, $data. Requires an element to represent a field. The subscript is the field name, and the value of the element is the field value!
?
When adding categories:
Categorymodel
?
?
Design Product List
?
?
Add Products
Show add-on form
Controller
Add a back-end commodity management controller
app/controller/back/goodscontroller.class.php
Add the first method action:
Addaction ()
?
Model
Already written!
View
Add a view template file:
App/view/back/goods_add.html
TAB Structure!
Each content is a table!
All the table is in a form:
<form>
<table>
<table>
?
?
Management of high-quality products by bit operations:
?
Switch tab:
JS used:
In the current project, add these two JS files at the same time:
?
Submit:
?
Other
Add a link to the left menu section to request the currently added item
Menu.html
Working with form data
Controller
Back-end Commodity controller insertaction
?
Model
Add a commodity table model
Add a Insertgoods method:
?
View
No to Template
?
?
?
?
File Upload
Basic Principles Operation Introduction
?
Refers to the file from the browser side, upload to the server side!
?
Data can already be uploaded from the browser to the server side!
?
What is the difference between file uploads and string submissions to the server?
?
The text box inside the form is the same as the file field, which is the normal data in the form!
Therefore, all data (including text boxes, and file fields) will be submitted to the server when the form is submitted!
?
However, the text box is not the same as the file field:
Data in storage or transmission, there are two kinds of encoding: byte code, binary code!
The normal string upload to the server requires byte encoding!
But the encoding for uploading files is: binary encoding!
?
However, by default, the browser does not process binary encodings! All data will be treated as byte-code strings!
?
So the first job of uploading a file:
Tell the browser that there is data in the current form that needs to be encoded in binary! (encoded data is made up of multiple encodings)
Take advantage of the form's properties:
Enctype= "Multipart/form-data"
When the browser touches the file domain, it knows to encode in binary form!
?
At this point, all data (string, file) is submitted to the form in the server
?
Server's PHP code to process the data:
Handling of strings: saving within $_post variables (in-memory)
Processing of files: The file will be received and saved to the temporary directory of the server system. Expiration date, end of current script!
?
?
User needs to persist temporary files (copy to other places) during PHP's script execution cycle
Using functions:
Move_uploaded_file ();//move files that have already been uploaded
Move result = Move_uploaded_file (temporary file, destination file)
The uploaded temporary file information is saved to the Hyper Global array variable $_files!
For each uploaded file, organize 5 messages:
Name: Original file name
Type: Types. Image/jpeg identifies the resource type method on the Text/html network. Called the MIME (multipurpose internel Mail Extension type) type.
Tmp_name: Temporary file name
Error: Wrong label (0,123467)
Size: sizes, Bytes byte
?
?
?
Upload function
?
?
?
?
?
?
?
The unique string = uniqid (prefix) function can get a unique string! And you can specify a prefix:
The suffix should be obtained from the original file name at this time!
The last point in the moniker string to the end of the substring!
STRRCHR (). Find the last occurrence of a substring, start at that position, and intercept to the end of the string!
?
?
?
Type of error
1:
File is too large to exceed PHP's maximum upload file limit
can be modified in PHP's configuration file:
?
PHP also has a limit on the size of all post data: All the form data added up, cannot exceed!
2:
The file is too large to exceed the limit of a hidden element within the form:
The element to appear before the File upload field
?
3:
File not uploaded
4:
No files Uploaded
6,7:
Save Upload File Temp folder Error!
?
?
Add File Upload Tool class
framework/tool/uploadtool.class.php
?
Design:
Save file Directory
Maximum file size
File type
Add the properties above to initialize the tool class object when it is constructed!
?
Add a way to upload a file
The error message should be saved to the property:
The judgment on rationality depends on the attribute:
The destination file should appear at the specified location:
?
The return value, the file name, and the names saved to the database should be relative!
?
?
Used in projects
Modify a form to add a product
App/view/back/goods_add.html
?
When adding items:
app/controller/back/goodscontroller.class.php
?
At this time need upload_dir, upload directory constant match!
To add a table of contents:
?
Test:
04mvc frame principle (8days) 06