php

4 minutes read
FPDF is a class to create PDF files with PHP, that is to say without using the PDFlib library. For those who are already familiar with FPDF, this post will show you how to output your PDF file using FPDF. There are 4 methods that you can use according to your own needs: Method 1: Saving the PDF to a file: $pdf->Output('yourfilename.pdf','F'); 1 $pdf->Output('yourfilename.pdf','F'); ...
6 minutes read
“How to Export MySQL data to Excel in PHP ?” This script will used to export data into .xls format from mysql database.You need to just copy this code and update database connection details. Below code will export mysql data into excel (.xls format) with every column name and value from your database . Export MySQL data to Excel in PHP <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'password'; $conn = mysql_connect($dbhost, $dbus...
8 minutes read
This post is about How to add and subtract dates from one another. For example, this simple code can calculate what the date will be 5 weeks before or after from any specific date like: 2016-01-06 (yyyy-mm-dd). Subtracting days from a date The following example will subtract 2 days from 2016-01-06. $Date = "2016-01-06"; $sub_newdate = date('Y-m-d', strtotime($Date. ' - 2 day'));   Adding days into a date $add_newdate = date('Y-m-d', strtot...
2 minutes read
If you want to strip line feeds, carriage returns, and tabs you can use: $string = preg_replace('/[\x00-\x1F\x80-\x9F]/u', '', $string); 1 $string = preg_replace('/[\x00-\x1F\x80-\x9F]/u', '', $string);   =>Note that you must use single quotes for the above two examples. If you want to strip everything except basic printable ASCII characters (all the example characters above will be s...
10 minutes read
How to manage international languages in MySQL database using php ? If you want to store multiple languages like Arabic, French, Hindi or Urdu to your MySQL database, default settings is not valid to do that to insert all languages in database. If you insert data in your database and database is not configured as I am going to show you in this tutorial then your data will be look like special characters निम and your data will lost .   So now i am going to tell you how to confi...
6 minutes read
How to upload a file from one server to another server using PHP cURL POST method. How to send files using PHP and cURL The cURL functions in PHP can be used to make HTTP requests to remote servers. The curl_setopt  method allows us a wide range of options to be set, but no one of them directly related to send files. But we can send files using cURL with special format for POST parameter values. Following script is usefull in sending a binary file via cURL. This code will make a request to http...
4 minutes read
cURL is a best library for file transfer via different types of protocols. cURL supports the transport via POST, GET, FTP upload and much more. cURL is also able to authenticate on the destination server or website. How to send files using PHP and cURL In this tutorial we want to upload a file to other (password protected) remote FTP server using a web form. <?php if (isset($_POST['Submit'])) { if (!empty($_FILES['file']['name'])) { $ch = curl...
3 minutes read
Some times we need the visitor’s IP address for validation, security, spam prevention etc. Getting the Visitor’s IP address is very easy in PHP. We can get the Internet Protocol (IP) address of any visitor by using PHP. Get Clients IP address using PHP script The easy way to get the visitor’s IP address in php is : // Get the visitors ip address <?php echo $ipaddress = $_SERVER['REMOTE_ADDR']; ?> 1234 // Get the vis...