Archive for the ‘PHP’ Category

Sunday August 14, 2011 21:21

Using AJAX and PHP together

Posted by Samuel Marian as PHP

In this tutorial i'll show you how to use PHP and AJAX together and get the results that you need. Here's an example of a function that executes a ajax request function execAjax(type){ $.ajax({ url: 'ajax.php?type='+type, dataType:...

Saturday July 16, 2011 15:34

Security Tutorial #2: Are you protected against sql injections?

Posted by Samuel Marian as PHP

There are alot of websites that are vulnerable to sql injections. In this tutorial i'll give you some examples with methods to protect you website.   Make your id from url (int) Let's assume that you get the id like this: $id =...

Thursday July 14, 2011 18:10

Security Tutorial #1: Password hashing

Posted by Samuel Marian as PHP

In the past two years i've used many methods to hash a password. The best method i used is by adding a salt and then encrypting with md5. If you encrypt a password without a salt is more easily (but almost impossible) to find the password. It's...

Thursday June 23, 2011 21:36

Transform image to Base64

Posted by Samuel Marian as PHP

Lately i've seen very often in email newsletters images embed with base64. If you send email newsletters containing image, this is the best way to send. First we try to open the file. $file_path = 'my-image.jpg'; if($fp = fopen($file,"rb",...

Tuesday May 31, 2011 21:35

How to make a search engine on your site. The good method.

Posted by Samuel Marian as PHP

Okay, so many people think that if you make a search engine on your site with query like the one below, it's okay. SELECT id,name,post FROM posts WHERE name LIKE '%my key%' But it's not! Because: Let's assume that you have a post called: My...

Saturday April 23, 2011 19:25

How to increase memory limit

Posted by Samuel Marian as PHP

Recently i needed to increase memory limit for executing a PHP script. And i think there are many of you who don't know how to do it. Here is a simple an example:

ini_set('memory_limit', '128M');

Tuesday April 19, 2011 11:00

How to transform arrays to objects and object to arrays

Posted by Samuel Marian as PHP

I haven't wrote any tutorial since two months (i've been very busy lately). Anyway, now i'll show you a simple way to transform arrays to objects and objects to arrays. Let's start with transformation from arrays to objects. function...

Hi here! In this video tutorial you'll see how to create a simple like/unlike button using jQuery and PHP. Download the code here: http://etiny.info/ynjtqc Download the database here:...

Sunday February 6, 2011 16:44

Using PHP cookies

Posted by Samuel Marian as PHP

Awhile ago we've talked about handling sessions in PHP witch is used to store data for a short time. Now i'll show you how to use cookies. The cookies are like sessions in a way. Cause they store data to, but for a long time (for how much you set)...

Saturday February 5, 2011 16:03

Create a file using PHP

Posted by Samuel Marian as PHP

Now i'll show you how to create a file using PHP's function fopen() Example: $fileName = 'myFirstFile.txt'; $fh = fopen($fileName, 'w') or die("can't open file"); fclose($fh); Explain: $fileName = 'myFirstFile.txt'; This is the file...