المشاركات

عرض المشاركات من يونيو, ٢٠١٨

How to Install Laravel 5.6 on Windows using Composer

صورة
Here let's see how to install laravel on windows using composer . Ever since its launch, laravel has become the most popular php framework and not without a good reason. It's a great alternative to CodeIgniter which is another popular MVC for php. Laravel ships with so many goodies out of the box than other frameworks do. Mastering laravel will definitely take some time, but the time spent is well worth it in the long run. And it will save loads of time in application development. Anyhow, here you are, planned to move on to laravel and want to install it for the first time. Without wasting the time, let's dive into the process of installing laravel on windows machine. System Requirements for Laravel: As of now, the latest laravel version is 5.6. And you have to make sure the below system requirements is met to install and use it on your machine. PHP >= 7.1.3 OpenSSL PHP Extension PDO PHP Extension JSON PHP Extension XML PHP Extension Ctype PHP Extension Mbst

How to Create and Download CSV File in PHP

صورة
Hi! Here we will see how to create a csv file and download it using php . CSV is one of the popular data storage methods used on the Web. Being a modern language, PHP has no problems handling various data formats including csv. It offers native functions to read and write csv files. With fputcsv() method, you can write data as a csv file and force it to download. Clicking on a file url (link) will just open it in the browser window without downloading. The exe and zip formats are an exception here. But in case you need to download it directly to client's hard disk, then you have to make use of the readfile() function. Let's see how to do it. PHP - Create CSV File: The following snippet creates a csv file named 'myfile.csv' on your current working directory. <?php // data array $user = array(1, 'Johnson', 'johnson@mydomain.com', 'Miami'); // filename $filename = 'myfile.csv'; // write to csv file $fp = fopen($filename, 'w&#

How to use PHP PREG MATCH function to validate Form Input

صورة
In this post we'll see how to do some basic PHP validations of form input using preg_match() function. One of the vulnerable spot in a website which attracts malicious hackers are the user input forms like registration form, contact form etc. Validating the user input before processing is the first and foremost step in securing the site. The validation includes checking if the data we received is in the right format and length. Generally it's a practice among web developers to do validation check at the client side (like java script). Still it’s easy for someone to break thru it and harm your site. So it's strictly advisable to do these validations on the server side (like PHP) . Generally we receive the form input as string and we can use preg_match with appropriate regular expression to check a required pattern in the input string. Preg Match Syntax Before dwelling into the validation process, here take a sneak peak at the syntax of preg match function.

How to Secure Passwords in PHP and Store in Database

صورة
Hi! Here let's see how to secure passwords in php . Developers have a huge responsibility when handling sensitive user data, such as password. They must take necessary precautions to store the password and other sensitive information in a secure manner. Old-school methods use the md5 algorithm to hash passwords and store them in the database. This really is not safe and vulnerable to attack. But thanks to the community, PHP 5.5 and higher comes with the password_hash function that generates one-way hash that is extremely secure to store passwords in the database. Below, we will see how to securely hash passwords, store them in the database and verify them against the user given password in php. PHP - Secure Way to Store Passwords: If you are a budding developer, these are some things to keep in mind when handling the password. Never store passwords as plain text. It's as good as not having a password at all. Never use MD5 or SHA1 for hashing. They are extremely fast an