How to start a php project
Hello every one many of people are wants to create their own website but lack of knowledge they are confused where to start how to start.
So we will discuss the every step where we can create any project like social media, online shopping, Hotel management and so on.
How to start
As we know that php is a server site scripting language, which means php codes are run only on server. So that we have to bulid our PC or laptop into a server, for that we simply had to install one software name xampp or also you can use wamp
( I assume that you are know how to install software)
1st step:
Install Xampp or Wamp. After installing the software go to C drive you will see a folder call Xampp (if you install Wamp folder name will be Wamp)
Under the folder you will find another folder call htdocs ( in case of Wamp the folder will be www).
Just open the folder and create a new folder . Give the folder name project_name ( whatever your project name)
We have completed our first step.
2nd step:
Open the application you just install and you will see there are some option. You just start the apache and MySQL service.
*Give the permission if they ask
Ok so we just completed our 2nd step. And here we make our computer as a server
Step 3: open you browser ( ex: chrome). And type localhost/project_name on URL and press enter enter.
For now you can't see anything there. But this the URL where your project will be shown.
So now we have to create our first php project
For that we need notepade++ or Dreamweaver. If you don't want to install this type of software you can simply use notepad but for the big project we need IDE
So just install notepad++ for now
We are all good to go
Most important things to create a website using php
First thing we have two ends front end and back end
Front-end: where user can write , update, filling up form and so on. We will create the front end using HTML, CSS, JAVASCRIPT AND php
Back-end: It is basically a database where whatever user write or fill up etc on frontend, everything is Store on backend (in database)
In php project we are actually deal with database (our backend) so everything user input or get results all are communicating with this database.
Just remember you just need four things remember and you will be expert on php
Php basic commands
1) Select
2) Insert
3) Update
4) Delete
That's it
These are the simple commands, you have to just play with this command.
So what's Select do ?
When we open flipkart we can see different type of product right. And when we open facebook we can see many photos and post right.
This things is done by this Select command . Actually select command fetch the data from the database(backend) and show it on our page (frontend)
Got it ??
Don't worry we will do the practical also how to use it
So next is
Insert , so insert command is user for inserting the data from the frontend to the database ( backend)
Example: signup form , where we put all our data and info. Everything we enter ilgoes to database and store our info for further use.
Update: As the name suggests update command is user for update data from the database. For example: changing password
Delete: delete command is very simple. This command is user for delete particular data from database.
How to write php code
So in your project folder just create a file and name it index.php, open the in Notepad++ or any IDE .
We are going to write our first php program
<?php
echo " This is my first page ";
?>
Here <?php is the opening tag, our browser will know that under this tag everything is php code.
echo is use for display in frontend. Whatever we write in echo user will see it.
How to run php file
Go to your browser and type localhost/project_name in the URL Bar and you will see
This is my first page
Which is we wrote in echo. Thats it
So now we know that how to display any string or number in php
This is very basic we need to do some advance code.
How to connect with database using php
For that we need a database
As we know that we have to create database in localhost/phpmyadmin section
Ok so lets start
Open a nee tab in your browser and type localhost/phpmyadmin
Click on Database
Give any name you want in our case lets give it test_project
Press create. And boom your database is created successfully.
Now we need some tables in the database
Tables in database
Why we need this table.
Well database is collection of data. We organised this data in various table.
For example: just think about Facebook
Assume that in Facebook we have many data like our username password, photo, our post etc.
How to organize data
To organize this data we have to create table.
Example:
For usename ,password, address phone no
We create a new table and named it User_login
Similarly for photo, post, comment we create a new table user_profile
So in this example we have two tables user_ login & user_profile under this table we organised this data in different coulmn
Create table in database
Select your database in our case our database name is test_project under this database there is a option call create table. Before pressing create table button we have to give the table name.
Type user_login and press create.
after clicking this we need to enter our column. As we decided that in user_login table we have username, password, address, phone no.
So we have to create this field. And also every field has its data type.
For username,password and address data type will be varchar . And for phone_no data type will be int also give the size. And press save
Thats it your table has been created
Similarly create the user_profile table
1 Comments