Secure login tutorial using PHP

There are a lot of tutorials posted online detailing how to create a login form in PHP but the vast majority of them offer really poor quality code which is not safe, open to SQL injection, CSRF attacks, brute force login, poor (or no) password encryption and XSS attacks.

Here, once and for all I will create a complete tutorials series on how to create a rock solid login script in PHP.

Continue reading Secure login tutorial using PHP

Laravel Eloquent – Integrity constraint violation: 1452 foreign key constraint or General error: 1005

Are you trying to set-up a foreign key constraint on one of your tables and you’re getting a 1452 error?

[Illuminate\Database\QueryException]
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

You might also get a General error: 1005

[PDOException]
  SQLSTATE[HY000]: General error: 1005 Can't create table `app`.`#sql-33d4_1a2` (errno: 150 "Foreign key constraint is incorrectly formed")

This is a MySql issue and not a Laravel one.

Continue reading Laravel Eloquent – Integrity constraint violation: 1452 foreign key constraint or General error: 1005

Installing OnlyOffice on Elementary OS

There are a number of office suites for Linux and I have used most of them. One I hadn’t heard about until recently was OnlyOffice, which is available for Windows, Mac and Linux for free. I believe it is a Javascript/Electron based application but it performs very well for your office needs so lets give it ago.

OnlyOffice on Linux Elementary OS

Continue reading Installing OnlyOffice on Elementary OS

Apache Invalid command ‘Header’

I recently had a vagrant box which was giving a 500 internal error and when checking the Apache error log I found the following error:

/vagrant/.htaccess: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration

The problem is that headers module is not loaded in Apache so you need to load it and restart. SSH into your vagrant instance (or open a terminal if you’re having this problem on your local LAMP stack) and enable the module:

a2enmod headers

Then restart Apache

service apache2 restart

Edit the bashrc file in Elementary OS

Editing the bashrc file in Elementary OS is an easy task, simply open it in your favorite text editor (Elementary OS comes with nano so you can use that).

sudo nano ~/.bashrc

Make any changes you need to that file and then press ctrl+o to save the file and ctrl+x to exit.

Don’t forget to reload your bashrc!

source ~/.bashrc

North Korean DNS Leak reveals North Korean websites

One of North Korea’s top level DNS servers was mis-configured today (20th September 2016) accidentally allowing global DNS zone transfers. This allowed anyone who makes a zone transfer request (AXFR) to retrieve a copy of the nation’s top level DNS data.

Continue reading North Korean DNS Leak reveals North Korean websites

Installing PHP Phalcon on Elementary OS

PHP Phalcon is one of my favourite PHP frameworks its so quick and powerful. Here is a quick guide on how to install it on Elementary OS. This guide presumes you are using Apache and have it working. If not please follow this guide to get Apache install on Elementary OS.

Continue reading Installing PHP Phalcon on Elementary OS

Install LAMP stack on Elementary OS

Unlike most other Linux distributions Elementary OS doesn’t come preinstalled with a LAMP stack. In this tutorial I will show you from start to finish. If you are interested in a certain part of the LAMP stack we have separate tutorials for you to read on those here, here and here.

Continue reading Install LAMP stack on Elementary OS