PHP form tutorial Phase13

Step 1 - PHP MySQL introduction
________________________________________
PHP MySQL tutorial



As you know by the help of PHP you can create dynamic website content. The dynamic content doesn't necessary require a database, however in most cases you have/need one. All of the content management systems, blogs or only a simple form processor use database. In the PHP world the most commonly used database is MySQL. So in the next section I will focus on how to use PHP and MySQL to create dynamic content. In this tutorial I will focus only PHP MySQL usage basics, and I suppose you have already an installed and properly configured system supporting both PHP and MySQL.

Check your configuration
To avoid any problem in the later steps you should check your actual configuration. To do this you need to create a simple Php file which calls the function phpinfo(). The file is really simple:
Code:
1.
If you open this site then you can check how your system is configured. The most important in this case the MySQL section of the output. It should look like something like this:

If you have no MySQL section then it means that MySQL access is not possible with the actual server settings. Ask your system administrator to configure it for you. (Later I plan to write a tutorial which guide you through the necessary steps.)

Creating a test database
In this tutorial I will use a MySQL database named test with a single table called users. Below you can find the sql code which creates the database, the table and inserts some default data.
Code:
1. CREATE DATABASE if NOT EXISTS `test`;
2.
3. USE test;
4.
5. CREATE TABLE `users` (
6. `id` INT(11) NOT NULL AUTO_INCREMENT,
7. `name` VARCHAR(100) DEFAULT NULL,
8. `city` VARCHAR(100) DEFAULT NULL,
9. `web` VARCHAR(100) DEFAULT NULL,
10. `age` SMALLINT(6) DEFAULT NULL,
11. PRIMARY KEY (`id`)
12. ) ENGINE=INNODB DEFAULT CHARSET=latin1;
13.
14.
15. INSERT INTO `users`(`id`,`name`,`city`,`web`,`age`) VALUES (1,'Mike','New York','www.eeeq.com',25);
16. INSERT INTO `users`(`id`,`name`,`city`,`web`,`age`) VALUES (2,'John','Dallas','www.ddd.com',37);
17. INSERT INTO `users`(`id`,`name`,`city`,`web`,`age`) VALUES (3,'Anna','London','www.eee.com',24);
18. INSERT INTO `users`(`id`,`name`,`city`,`web`,`age`) VALUES (4,'David','Oxford','www.fff.com',19);
19. INSERT INTO `users`(`id`,`name`,`city`,`web`,`age`) VALUES (5,'Julia','New York','www.aaa.com',20);
20.


Explore more on PHP form creation and handling :


Post a Comment

Previous Post Next Post