Stream of consciousness php basic learning Notes

Source: Internet
Author: User
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 ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.