The complete programming solution for the beginner
How to Insert data in Database using Php
Data can be entered into MySQL table by executing SQL INSERT statement with Php mysql_query( ) function. Before this make sure you have created database and table in PhpMyadmin. Below is very simple example to enter data in MySQL using HTML form. Because in live project value are take from HTML form and captured using Php script and this captured value finally inserted in MySQL Table .
Example :- Creating database and table :-
Open PhpMyadmin using username as root and keeping password field blank. Now click on new located on left side. After clicking on window will open asking for database name. Provide the database name as record and click OK. Now new window will open asking table name and number or columns. provide the table name as employee and give 8 numbers of columns and click OK.
Name
Contact
email
Password
Gender
Language
Nationality
Address
Making connectin with PhpMyadmin connection.php
HTML Code (insert.php)
Save this as insert.php
PHP Code(data.php)
Save this as data.php
Description :- For Php code Include_once( ) function is used to inherit the code of connection.php. Strtolower( )function is used to convert the string into lower case. Implode( ) function is used to insert the comma between the string value. Empty( ) function is used to check whether the input field is empty or note. Mysql_query( ) function is used to execute the SQL query.
The functioncheck( ) is used to restrict the user to perform anti programming.
No comments:
Post a Comment