An example to insert some data in to the MySQL database ...
An example to insert some data in to the MySQL database using PHP
1. Create a Index.php page in a new folder(“764”) created under public_html folder present in your home directory
To use a PHP script on your web page, you just need to end the file name with .php and make sure the permissions on the file are set correctly. Any files to be accessed by the web server must be publically readable, but none of your PHP files (nor the directory containing them) may be group or publically writable. Following are the commands you can use for setting the permissions in linux:
chmod 755 public_html
chmod 644 public_html/764/index.php
The PHP page will have two simple text boxes for the user to enter some data in to it. Label them to be Firstname and Lastname.
INDEX.PHP
A small example page to insert some data in to the MySQL database using PHP
Firstname:
Lastname:
We also need to make sure that the form method attribute is “post” so as to access the data being entered in a reliable way in the next page being directed “insert.php” so that the data being entered in the textboxes can then be saved to the database in the “insert.php” page.
[pic]
2. To connect to MySQL :-
Before you can access your MySQL database, you must contact the system administrators to request an account.
Once the administrators have notified you that your account has been created, you may connect using the following instructions.
Go to and type your MySQL ID and password being given.
[pic]
3. Now enter the new table name “nametable” , number of fields in that table as “2” and hit GO button.
[pic]
4. Enter the field names to be “firstname” and “lastname” and keep the length attributes to be “20” for both the fields. The default type of VARCHAR is kept as it is.
[pic]
5. After the table fields are being created, the following screen will be shown to you.[pic]
6. Now we need to make a connection to the MySQL database and then send this entered data from our textboxes. For that we create a new PHP page “insert.php” and use the following connection strings to the connection variable $con
After making a connection, a SQL query is being written to enter this data in to the MySQL database being created (“nametable”)
To tell the user that the data is being entered we set the echo to "1 record added"
INSERT.PHP
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- mysql database vs schema
- how to insert date formula in excel
- how to insert current date in excel
- how to insert a row in excel
- how to insert a chart in excel
- mysql database data example
- how to insert text file in excel
- how to insert grid lines in excel
- mysql database schema table
- select mysql database for schema output
- turning someone in to the irs
- how to insert a signature in word