Creating Reddit Login Button in PHP

In this tutorial I will show you how to create a Reddit login button for your website using PHP. What is OAuth? OAuth is a protocol used to allow secure authorization to websites and applications to access user information. There are two versions of OAuth, 1.0 and 2.0. In this post we will use OAuth 2.0 to build a Reddit login system.

Ajax Image upload & Resize with PHP ImageMagick & jQuery

PHP GD library is more than enough for image processing, it supports numerous image formats and offers enough capabilities. But sometimes enough is not enough, sometimes we want to try out ImageMagick, just for the sake of performance, code clarity or just to explore more functionality. So today instead of using PHP GD, we are going to create an image upload and resize script using ImageMagick (PHP) and jQuery.

Test send PHP emails locally (xampp) Windows

If you are required to test the functionality of PHP mail in your projects, which is without having to use external mail server, you can try these steps which will allow you to send and open emails locally. I assume you are running XAMPP server on your computer, it should work fine with WampServer too without any configuration.

Backup Website and Database using PHP exec()

PHP exec() function is usually disabled in most shared web hosting servers because of security reasons, but if you are on VPS or dedicated server, you could use exec commands to backup your website or mysql database. Before you start, using code below check whether exec is enabled, if it fails you should ask your host to make sure it is even allowed! 123if(function_exists('exec')) {     echo "enabled"; } Back-up folder The following exec command should back-up your website folder. 12345678$folder_to_backup = "/path/to/folder"; $backup_folder = "/path/to/backup/folder"; exec("tar -cvf $backup_folder/backupfile.gz $folder_to_backup/* --exclude='$folder_to_backup/*.gz'", $results, $result_value); if ($result_value == 0){     echo "The archive has been successfully created!"; } else {     echo "Archive creation failed!"; } Back-up MySql database To back-up your MySql database, simply copy/paste this code in a PHP file, change to your MySql credentials and run. 123456789101112$mysql_host = "localhost"; $mysql_user = "username"; $mysql_pass = "password"; $mysql_database = "my_database"; $backup_folder = "/path/to/backup/folder"; exec("mysqldump -h $mysql_host -u $mysql_user -p$mysql_pass $mysql_database  > $backup_folder/my-sql-backup.sql", $results, $result_value); if ($result_value == 0){     echo "The MySql backup successfully created!"; } else {     echo "MySql backup creation failed!"; }