Get user’s current location based on IP

Welcome back to shortlearner.com, in this post today we will see how to find user’s location with having their IP address. so most of the time we need to access the user’s location to analysis the location wise client base.
In the below PHP script first of all we will fetch the user’s IP address by using pre-defined PHP function and store the IP address in a $ip_address variable.


so simply we will pass this IP address to our third party platform that will return as a JSON array that having country, country code, state, city , zip, time zone, longitude and latitude as well.
here we are performing this task with the help of curl functionality.

Get user current location based on IP

so we got this JSON response.

Also Read
How to Install PHP on CentOS.
How to Send Attachment on mail using PHP.

PHP Login Script With Remember me.
Unable to create a directory a wordpress error

How to integrate Razorpay Payment Gateway using PHP.
Change password using javascript, php and mysqli.
Password and Confirm Password Validation Using JavaScript

how to Calculate age from dob using php

Welcome back to shortlearner.com , today in this post we will see how to find the age of the user on the basis of their date of birth.
so we are going to write a program in php that will help us to calculate age.

calculate age from dob

in the below program we are declared a variable $birthDate with having a date in mm/dd/yyyy format. after that we are using predefined php function explode(), so with the help of that function we will explode the date to get month ,date and year as well. after that we will calculate the age of user on the basis of user’s date of birth and current date.

Also Read
How to Install PHP on CentOS.
How to Send Attachment on mail using PHP.

PHP Login Script With Remember me.
Unable to create a directory a wordpress error

How to integrate Razorpay Payment Gateway using PHP.
Change password using javascript, php and mysqli.
Password and Confirm Password Validation Using JavaScript

How to use CKEditor as form input?

Welcome back to shortlearner.com, today in this post we will see how to integrate ckeditor in our web based projects.
so before start the integration we should take an small overview and knowing the amazing benefits and features of CKeditor.
most of the time we need an editor that will help us to bold, italic and underline the paragraph and also help us to upload multiple images with in the paragraph.

ckeditor complete code

Amazing Features

  • Applying Styles to Editor Content
  • Applying Block-Level Text Formats
  • Basic Text Styles: Bold, Italic and More
  • HTML Output Formatting
  • Inserting Code Snippets
  • Pasting Content from Microsoft Word
  • Removing Text Formatting
  • Setting Text and Background Color
  • Source Code Editing
  • Table Creation
  • Using the Copy Formatting Feature

Also Read
How to Install PHP on CentOS.
How to Send Attachment on mail using PHP.

PHP Login Script With Remember me.
Unable to create a directory a wordpress error

How to Integrate

It is very easy to implement the features of CK Editor in our web application.
just follow the below steps

step1
Add this CKeditor JavaScript file at head section of our web page

Step2
Now we will add our textarea tag and a small lines of JavaScript code.

Complete Code

Demo

How to upload form data and image file using Ajax

Welcome back to shortlearner.com, today in this post we will see how to store user information and photo into MySQL database using Ajax JQuery and PHP. in our previous post we learn how to force fully download a file from the server with the help of php.

upload image with ajax php

so before start this tutorial we should take an overview of the scenario of the post.
we are designing a responsive signup form with username, email and multiple file options with the help of HTML, CSS and Bootstrap.


after submission of the form we will call a AJAX request with the help of JQuery, and we will send all the form information into our signup.php.

in signup.php we will creating a database connection and also validate the form data and file’s extension as well.

if file extension will pdf,JPG,JPEG and png than it will allow for further request otherwise the error will show on the user’s screen.

If user upload multiple files than we use foreach loop and check extension of each and every file and convert there into a unique name via using predefined PHP rand() function.

now after that process we will simply move all the files into our defined path and Insert all the data into database applying insert query and store all the data into our user table.

Also Read
How to Install PHP on CentOS.
How to Send Attachment on mail using PHP.

PHP Login Script With Remember me.
Unable to create a directory a wordpress error

How to integrate Razorpay Payment Gateway using PHP.
Change password using javascript, php and mysqli.
Password and Confirm Password Validation Using JavaScript

How to force download file from server-PHP

Welcome back to shortlearner.com, today in this post we will see how to force fully download a file from the server with the help of php.
In out previous post we learn how to import csv file into mysql database using php.

download file using php

so first of we need to understand overall scenario before downloading file from the server.
so i was created a image folder in a root directory of my project. there is a image file inside img folder with the name of test.jpg.

now we are writing a code for downloading this test image from the server without showing our img path to our end user because if we show our img folder in url than user can view all our images or files from the directory.

In the below code i am crating a index.php file which having a download button. so whenever user click on that button our download script will run and file will downloaded.

index.php

after click on the submit button we use the below code to download file from remote server to our system.

Also Read
How to Install PHP on CentOS.
How to Send Attachment on mail using PHP.

PHP Login Script With Remember me.
Unable to create a directory a wordpress error