Create dynamic website with php and mysql

How to develop a website using HTML, CSS PHP and MySQL?

Step-by-Step guide to create dynamic web pages using HTML, CSS, PHP & MySQL.

This post is for the persons who are beginners in the web development field.

In this post, I will cover everything step by step starting from designing and development. At the last we will see how to deploy the website online.

Steps to create a website:

  1. Download and install a code editor on your computer for writing HTML, PHP etc. code.
  2. Download and install XAMPP Server on your computer.
  3. Start Apache and MySQL server.
  4. Start designing and developing your website with SQL queries.
  5. Test your website on your computer.
  6. Deploy your website on online server.

Step 1: Download a code editor

There are very code editors available for free like visual code, notepad++, Sublime etc. Download and install any one of them.

Step 2: Download XAMPP

Download and install XAMPP Server on your computer. XAMPP is the most popular PHP development environment. XAMPP is a completely free, easy to install Apache distribution containing MariaDB, PHP, and Perl.

Читайте также:  Python online code test

XAMPP is an abbreviation for cross-platform, Apache, MySQL, PHP and Perl, and it allows you to build and run PHP offline, on a local web server on your computer. This simple and lightweight solution works on Windows, Linux, and Mac – hence the “cross-platform” part.

Step 3: Start Apache and MySQL

After installing the XAMPP, you have to run it on your computer. Also make sure you start Apache and MySQL Server. If your Apache and MySQL Server, it will show as the image below.

create dynamic website using php

Step 4: Write HTML, CSS, PHP, SQL code

Now it is the time to write your HTML and PHP files.
Create a separate folder for your website in htdocs folder of XAMPP. You can find your XAMPP in c. (C:\xampp\htdocs). Inside this folder, you have to keep your coding files.

Tip: Your homepage will be known by name: index.html or index.php.

You can create the database for your website through phpmyadmin.

Step 5: Test your website locally on your computer

Keep testing your code in your browser through local host. This is XAMPP comes into handy for this purpose.

Step 6: Deploy your website

When your website is complete. You have to purchase a hosting and a domain for your website. Hosting provider allocates space on a web server for a website to store its files

When to use index.php instead of index.html?

you will have to choose the PHP extension (.php) when you want php code to be executed in the file. PHP code is code between the opening tags.

When no PHP code should be executed you can use the .html extension.

Usually when using the .php extension you are telling the web server, that it should use a PHP interpreter to process the file before it will be delivered to the browser. The PHP interpreter will then replace all content between the by the output of the PHP code. Just as if you wrote it manually. The processed file will then be delivered to the browser.

Источник

Creating dynamic Web sites

The Web is no longer static; it’s dynamic. As the information content of the Web grows, so does the need to make Web sites more dynamic. Think of an e-shop that has 1,000 products. The owner has to create 1,000 Web pages (one for each product), and whenever anything changes, the owner has to change all those pages. Ouch! Wouldn’t it be easier to have only one page that created and served the content on the fly from the information about the products stored in a database, depending on the client request? Nowadays sites have to change constantly and provide up-to-date news, information, stock prices, and customized pages. PHP and SQL are two ways to make your site dynamic.

PHP for Creating dynamic Web sites

PHP is a robust, server-side, open source scripting language that is extremely flexible and actually fun to learn. PHP is also cross platform, which means your PHP scripts will run on a UNIX®, Linux®, or Windows® server.

MySQL for Creating dynamic Web sites

SQL is the standard query language for interacting with databases. MySQL is an open source, SQL database server that is more or less free and extremely fast. MySQL is also cross platform.

Installing Apache server routines for Creating dynamic Web sites

First we will install the Apache server routines in the Linux environment. To install these packages you need root access to your server. If someone else is hosting your site, ask the administrator to install them for you. Installing Apache is relatively simple. First download the Apache archive, apache_x.x.xx.tar.gz (the latest I downloaded was apache_1.3.14.tar.gz) from the Apache site and save it in /tmp/src directory. Go to that directory:

Extract the files with the command:

# gunzip -dc apache_x.x.xx.tar.gz | tar xv

replacing those xs with your version number. Change to the directory that has been created:

Now to configure and install apache, type the commands:

# ./configure --prefix=/usr/local/apache --enable-module=so # make # make install

This will install Apache in the directory /usr/local/apache. If you want to install Apache to a different directory, replace /usr/local/apache with your directory in the prefix. That’s it! Apache is installed. You might want to change the default server name to something of real value. To do this, open the httpd.conf file (located at /usr/local/apache/conf) and find the line starting with ServerName. Change it to ServerName localhost. To test your install, start up your Apache HTTP server by running:
# /usr/local/apache/bin/apachectl start
You should see a message like “httpd started”. Open your Web browser and type “http://localhost/” in the location bar (replace localhost with your ServerName if you set it differently). You should see a nice welcome page.
Installing MySQL Next comes MySQL. We will follow the same procedure (replacing those xs again with our version number). Download the source from the MySQL site and save it in /tmp/src.

# cd /tmp/src/ # gunzip -dc mysql-x.xx.xx.tar.gz | tar xv # cd mysql-x.xx.xx # ./configure --prefix=/usr/local/mysql # make # make install

MySQL is installed. Now you need to create the grant tables:
# scripts/mysql_install_db
Then start the MySQL server:
# /usr/local/bin/safe_mysqld &
And test your installation by typing:
At the password prompt, just press Enter. You should see something like:

Welcome to MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 to server version 3.22.34 Type 'help' for help. mysql>

If you see this, you have MySQL running properly. If you don’t, try installing MySQL again. Type status to see the MySQL server status. Type quit to exit the prompt.

Installing PHP for Creating dynamic Web sites

We will follow a similar procedure to install PHP. Download and save the source from the PHP site to /tmp/src:

# cd /tmp/src/ # gunzip -dc php-x.x.xx.tar.gz | tar xv # cd php-x.x.xx # ./configure --with-mysql=/usr/local/mysql --with-apxs=/usr/local/apache/bin/apxs # make # make install

Copy the ini file to the proper directory:

cp php.ini-dist /usr/local/lib/php.ini

Open httpd.conf in your text editor (probably located in /usr/local/apache/conf directory), and find a section that looks like the following:

# And for PHP 4.x, use: # #AddType application/x-httpd-php .php #AddType application/x-httpd-php-source .phps

Just remove those #s before the AddType line so that it looks like to Creating dynamic Web sites:

# And for PHP 4.x, use: # AddType application/x-httpd-php .php .phtml AddType application/x-httpd-php-source .phps

Save your file and restart apache Creating dynamic Web sites:

# /usr/local/apache/bin/apachectl stop # /usr/local/apache/bin/apachectl start

Creating dynamic Web sites Then test whether you have PHP installed properly. Type the following code in a text editor and save it as test.php in a directory accessible by your Web server :

Creating dynamic Web sites PHP and ASP

Creating dynamic Web sites

Set the permission of the file to executable by typing at console chmod 775 test.php, and then view it with your browser. You should see a detailed description of the environment variables in PHP . If you don’t, then PHP was not installed properly. Try reinstalling it. Make sure there is a section “MySQL” in the php info; if not, MySQL connectivity will not work for Creating dynamic Web sites.

Share this:

Источник

Оцените статью