Stream of consciousness php getting started basic learning notes addAdmin (add administrator)
Process:
AddAdmin. php (view interface) [pass the act value] ---> doAdminAction. php (total processing) uses include. php contains all functions ---> According to the passed act in admin. inc. find the appropriate function in php ---> call mysql. func. insert () in php into the database
A form, action = "doAdminAction. php? Act = addAdmin ", and upload it to addAdmin
Act = addAdmin indicates that the previous act parameter is passed, which corresponds to the addAdmin operation.
In doAdminAction. php, act is passed in through $ _ REQUEST ['AC '].
Set an include file, which contains all the php files of require_once, so that you do not need to introduce a lot in each file, as long as you include an include. php file.
Include all function methods in the core folder
The above addAdmin function is in admin. inc. php in the core folder.
First, use the $ _ POST method to pass all the data in the form and save it in an array $ arr. the name attribute of the form input determines the label after the data is transferred. Finally, insert the database using the insert () function.
The insert () function is a function of all database functions in mysql. func. php.
Note: (1) join (): combines array elements into a string. the array_keys () function returns a new array containing all the key names in the array.
(2) the array_values () function returns an array containing all the key values in the given array without retaining the key name.
(3) the mysql_insert_id () function returns
Take the example above to introduce the working principle of insert:
Normal SQL statement insert database insert (table name) (key name) values (key value)
Array_keys () and array_values () return a new array containing all the key names and key values of the array.
Finally, execute this handle using mysql_query ($ ssql ).