Basic PHP setup with Xampp Server Step by Step..

First You need to have few things in order to start learning PHP

PHP is server side scripting language which runs only on server there are are two servers we need in order to start with PHP we will be using Xampp server which used very comman in industry.

1.Apache Server for Hosting the PHP website(Scripts)

2.MySQL database(PhpMyAdmin)

3.Subline Text(IDE)

You can use any IDE but sublineText is light weight and easy to handle its pretty simple to use.

STEP 1: install Xampp server after installing start the Apache server and phpmyadmin

STEP 2: Open and Start Apache and MySql server.

Note:- Sometimes it will not start because if the port is not available like Skype takes the same port which Apache needs port:80 so at that time check NetStat cmd to check the availability of port in your computer.

 

xampserver

STEP 3: once you start all server just goto install location of xampp where you will find htdocs Floder which will be your Hosting Space there you can store your files and later your can run then by calling server name and file address.

xampp-installed-location

STEP 4: Create Simple PHP file to add two number which will give you result in browser.

Addition.php

<?php

$one = “10”;
$two = “20”;

$Result = $one + $two;

echo $Result;
?>

STEP 5 : need to Create Database and run following code to insert data into database.

Create DataBase with the name Demo and create table total(ID , Total) fields.

refer video to create Database and Tables…

&lt;?php

include('Addition.php');
$DB_USER='root';
$DB_PASS='';
$DB_HOST='localhost';
$DB_NAME='Demo';
$mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}

$mysqli-&gt;query("SET NAMES 'utf8'");
$sql="INSERT into 'total' ('id', 'total') values ('$result')";
$result=$mysqli-&gt;query($sql);
while($e=mysqli_fetch_assoc($result)){
$output[]=$e;
}

print(json_encode($output));
$mysqli-&gt;close();

?&gt;

 

Hope this will help those who have any problem they can post Queries in the comment section…

Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *