Posts marked with "PHP" in categories

Create Your Own URL Shortening Service Using PHP & jQuery

I made a URL shortening service a year back using PHP & jQuery. It was pretty simple. You should know the concept of URL Shortening. The concept is simple. When a user sends a request to short a URL, PHP will check if the URL is valid. If it’s valid then PHP will make a string of 5 or 6 characters. A folder is created with the name of this string and an index.php file with header function code is created in this folder.... [READ MORE]

Uploading An Image Using AJAX In jQuery With PHP

As you know AJAX is the method of sending data without refreshing the page. Now I’m going to tell you how to upload images using AJAX in jQuery. For This You need to Download the jquery.form plugin from here. The Minimum requirement for this plugin is jQuery version 1.5 or later. Download Demo A Sample of uploading image using AJAX in jQuery is shown below : <div> Now Let&#8217;s start on the code.... [READ MORE]

Send Email using GMail SMTP server in PHP

This tutorial was suggested by SWDS. To send an e-mail using GMail’s SMTP server, you need extra help. Download the latest version of Swift Mailer Package from here. This mailing class is simple, that’s why I recommend you to use Swift Mailer. If you have enabled application specific password feature on Google Accounts, you may have to generate a new application password and use that password for SMTP authentication. Otherwise the example won’t be able to login to your google account.... [READ MORE]

Execute Command Without Waiting For It To Finish

If you just execute a terminal command using exec or system in PHP, the page will only load completely until the command has been finished. If you are running commands to run a websocket server, the page will not load, because the start server command won’t terminate. So to avoid this problem you should just do a simple trick, Just add > /dev/null & after the command you’re running.... [READ MORE]

Upload Image To Remote Server With PHP cURL & Handle File in Remote Server

If you want to upload images to an external server which is uploaded to your site by a client, you are at the right tutorial. For this submission we will use 2 files : form.php – The Page Where we will show the client the form. This file also sends the uploaded data to the external server. handle.php – The Page on the external server which receives the uploaded data from form.... [READ MORE]

Split Name in PHP and Javascript

If you have a user with a long name and want to short it because it won’t fit into the element that contains the name, you can either do it on the server or the client. In this post I am going to tell you how to accomplish this with PHP and JavaScript. Suppose We have a user named Paul Steve Panakkal (my cousin). To separate the first name, middle name and last name you can do the following in PHP :... [READ MORE]

Prevent Directory Listing using HTACCESS

If you don’t want your site users to see your directory listing, you can do a simple trick in .htaccess file. Here is a screenshot of a directory listing on Apache Server : Now, to disable directory listing of all types of files, type in the following code in .htaccess : IndexIgnore * This will change the directory listing to this : The empty directory listing looks ugly. To make it beautiful, you can add an index page for all directory listings without adding each index files on each directory.... [READ MORE]

Create MySQL Injection free Secure Login System in PHP

There were a lot of people who created tutorials to create a PHP Login System. But they were all vulnerable to MySQL Injection. In this post I’m going to demonstrate a login system free of this vulnerability. It is very secure. There are mysqli and PDO in PHP to escape these injections. We are going to use **PDO ( PHP Data Object **). Download Demo UPDATE – logSys There is a new, free, better Advanced Login System which you can check out here.... [READ MORE]

Generating Random String in PHP

In PHP you can generate random number by using rand function, but there is no specific function to generate a random text or string. In this post I’m going to show the function that will generate a random string of length mentioned. Here is the function: function rand_string($length) { $str=""; $chars = "subinsblogabcdefghijklmanopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $size = strlen($chars); for($i = 0;$i < $length;$i++) { $str .= $chars[rand(0,$size-1)]; } return $str; } Usage To generate a random string use rand_string() function with the parameter of length of the to be generated string.... [READ MORE]

Preventing double encode of URL in PHP

There is no practical way to check whether an URL is encoded or not to encode if it’s not encoded. But you can do encode the URL by first decoding like below: $string = url_decode($url); And then you should encode as to prevent double encoding. $string = url_encode($url); By doing this we can prevent double encoding of URL‘s.... [READ MORE]

Follow/Subscribe

Telegram 

Mastodon  Twitter

GitHub GitLab

Subdomains

Demos  Lab

Past

This blog was once on WordPress. Now a static site. See source code on

GitLab