Hide or remove controller name from url in Yii 2.0

You can hide or remove controller name from url in Yii 2.0 through configuring rules for urlManager component. You can hide controller name from url even if your pages are generated dynamically using database after reading this article.

First of all you have to enable pretty permalinks. After that let’s try to understand how to configure application rules by simple examples.

Read More

Creating SEO friendly URL in Yii 2.0 framework

Yii 2.0 framework has a major improvement over version 1.1. Creating SEO friendly URL in Yii 2.0 framework has been a lot easier. All is just turning pretty url ‘on’ to your Yii application and writing very few rewrite rules in htaccess file, enough to hide index.php from your URL and to make them SEO friendly.

Read More

Run PHP from command line in windows and xampp

To run PHP from command line in windows you just have to add php executable file path to system variable correctly. If you have installed XAMPP, and want to use command line to run PHP on Windows, here is this helpful article for you.

I have already installed XAMPP in my local pc having windows 7 OS. The most important part is setting path system variable and after learning the steps I described below along with pictures, you will be able to do the same for other OS and programming languages too.

Read More

Get the last inserted ID of a MySQL table in PHP

Get the last inserted ID of a MySQL table is a simple query to obtain the primary key of the record you just inserted to the table. Here I have explained the query using PDO as well as Mysqli.

Also, I have abbreviated few points while using PDO or if you are trying to get the last inserted ID of a MySQL table in PHP using other methods.

Read More

PHP return data from loop in function

The idea behind writing a post to return data from loop in function in PHP just came into my mind because a fresher was trying to set up a function to return data from loop and hoping it would then run a return each time within the loop and the function would echo each out one by one.

Read More

Using PHP to extract img src alt and title from HTML

Using PHP to extract img src alt and title from HTML is quite easy and this can be done in two ways. Either using PHP regular expression matching or using the Document Object Model (DOM).

Here is a DOMDocument/DOMXPath based example to extract img src alt and title from HTML using PHP.

Read More

Display Data in Multiple Columns from Database using PHP

In some scenario we need to display data in multiple columns in a HTML table where each row from database keeps data for a single column. The data can be text, image or mixture of both. This article will guide you display data in multiple columns from database using PHP.

Read More

Setting up foreign key in phpMyAdmin

Setting up foreign key in phpMyAdmin is quite easy. With help of this step by step pictured tutorial, you will be able to set foreign keys within your tables.
Here in the example we have three tables. ‘products’, ‘category’ and ‘product_category’. You can see structures of these tables in the picture below:

Read More

Methods and tips to prevent SQL Injection attacks

In this article we are presented with few methods and tips to prevent SQL Injection attacks in our web application.
In simple term when an application takes user data as an input, there is an opportunity for a malicious user to enter carefully crafted data that causes the input to be interpreted as part of a SQL query instead of data in our application.

Read More

What is SQL Injection

SQL Injection is the hacking technique which attempts to pass SQL commands (statements) through a web application for execution by the backend database. If user input is inserted without modification into an SQL query, then the application becomes vulnerable to SQL injection

Read More

[ Page 3 of 4 ]