Write a form submission first, this is a simple backstage ... In fact, you can also pass phpadmin ... Phpadmin also called backstage ... Everything is in order to be more convenient and quick ...
First, a template, a simple point, is to understand the implementation of the process and principles
<formAction= "check.php"Method= "POST">Add Data:<inputtype= "text"name= "User"><inputtype= "Submit"value= "Submit"></form>
View Code
It will be changed a while, for the time being ...
Get an entrance.
It's called admin.php.
Direct copy of the front entrance, so nice?
<? PHP Define // Project name Define // Project Path Define (' App_debug ',TRUE// turn on debug mode include // introducing the thinkphp core file ?>
Build It!!!
I was relieved to see the controller ...
Database configuration to copy the previous good ...
<?PHPreturn Array( //' Config item ' = ' config value '//' USERNAME ' + ' admin ',//assignment//database configuration information' Db_type ' = ' mysql ',//Database Type' db_host ' = ' localhost ',//Server Address' Db_name ' = ' confluence ',//Database name' Db_user ' = ' root ',//User name' Db_pwd ' = ' root ',//Password' Db_port ' = 3306,//Port' Db_prefix ' = ' think_ ',//database table prefix//other project configuration Parameters//...);?>
I heard that can be combined with configuration items, can also be single-entry implementation, and later ...
The previous method was this ...
Three lines of code ... But the effect is one to the page to do the addition of data ... What about my form?
Baidu a bit of tutorial, refer to Http://www.thinkphp.cn/extend/229.html
I don't know what the model is, it doesn't matter ...
Baidu knows this thing.
<form method= ' post ' action= "__url__/modfiy" >
This is theoretically possible ...
I don't know what version of this tutorial is.
Look at the template first.
The template came out and the code was changed.
Ok ...
Directly found in the project "Runtime", delete, clean down the cache
Got a half-day is the HTM code wrong ...
<form action= "check.php" method= "__url__/insert" >
Should be...
<form action= "__url__/insert" method= "POST" >
Can already jump to this function ...
Public functionInsert () {$Form= D ("form"); if($Form-Create ()) { if(false!==$Form-Add ()) { $this->success (' data added successfully! ‘); } Else { $this->error (' Data write error '); } } Else { //Field validation Error $this->error ($Form-GetError ()); } }
What does this function specifically mean?
My watch is admin ... If the function does not have the admin such thing, I feel logically certainly is not possible ...
Look at this http://www.thinkphp.cn/info/101.html.
Call to a member function GetError () on a non-object
We use the D function in the insert operation method, and the M function is different, the D function needs to have the corresponding model class
I said ...
Change ...
<?PHP//This class is automatically generated by the system and is intended for testing purposes onlyclassIndexactionextendsAction { Public functionindex () {$this-display (); } //working with form data Public functionInsert () {$admin= M (' admin '); if($admin-Create ()) { $result=$admin-Add (); if($result) { $this->success (' Operation succeeded! ‘); }Else{ $this->error (' Write Error! ‘); } } }}
Ok...
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。 。。。。。。。。。。。。。。。。。。。。。。。
Write the entry file first
Configuration database
Add a template
Edit Controller
View foreground effects
thinkphp Add a background idea and add data features