Please understand, this tutorial is for absolute beginners and its pretty much straightforward and presented with some really basic jquery syntax examples.
A blog about different techniques and tutorials about web programming language especially Javascript , jQuery and PHP/MySQL
Tuesday, 28 August 2012
Sunday, 26 August 2012
Choices of Hosting your PHP website
In learning, PHP/MySQL, the end game is presenting your website to viewers. So, You will need to shift your website from your computer to server of some very good hosting company. So what really is a web host ?
A web host is a company which provide space and constant availability of your website to website users. Obviously, for quality services, they can charge you monthly fee.
There are 3 kind of Hosting Options for your PHP website
A web host is a company which provide space and constant availability of your website to website users. Obviously, for quality services, they can charge you monthly fee.
There are 3 kind of Hosting Options for your PHP website
- Shared Hosting
- VPS - Virtual Private Servers
- Fully Dedicated Hosting
Saturday, 25 August 2012
Top 3 PHP Frameworks
There are many free (open source) PHP frameworks available for download to create robust, dynamic websites in php very fast. But first, let's visit the definition.
There are many PHP frameworks available, some of them include
A framework is an application which helps to create websites in less time by providing the common activities in a website. Like, a framework usually contains code for validation, minimize security flaws and validate input data
Code Igniter - trusted PHP framework
There are many PHP frameworks available, some of them include
Thursday, 23 August 2012
Sending Variables from One Page to Another Page in PHP
Another major module in programming languages is sending variables from one page to another page. Usually, for many reasons we need to send some data on one page to be shown on another page. There are two major ways to send variables from one page to another page.
- Sending variables by using forms.
- Sending variables without forms.
Top 5 PHP resources Online
There are many websites online which have thousands of scripts for free download. You can download and install it on your website or download it and try to see the coding style and learn it. Though, some scripts have licensed version, you can use them to learn the code styles instead using it on your website. Mostly, all kind of scripts are available online. There are dozens of free shopping carts in php like open cart etc, there are CMS like joomla and wordpress which are open source as well.
PHP/Mysql Follow up !
PHP/Mysql Follow up !
In previous tutorials, we have discussed in details how to connect to mysql server and how to execute sql queries.We are going to just go-through again about database connectivity in php- We will connect to database server with mysql_connect()
- We will select database name with mysql_select_db()
- We will execute sql command using mysql_query()
How to prevent sql injection in php
How to prevent sql injection in php !
SQL injection mean if any user can send his own custom query to our database. SQL injection is the most common problem when newbie or non-professional programmers develop websites.
For example : Here is a sql command
SQL injection Threat |
$pass=$_POST[‘password’];
Select * from tablename where user=$user and Pass=$pass
Wednesday, 22 August 2012
How to protect PHP website in 3 steps
How to protect PHP website in 3 steps
if you are a website programmer or developer, never ever trust website viewer. Instead think viewer as an enemy that must be fed with the best of the food but never allowed to enter in the castle.
Not all readers are trustworthy, in mostly less than 0.01% of your readers can be hackers and they can harm your website if you trusted them. Here, we are providing just 3 steps to safeguard/protect a php website.
Not all readers are trustworthy, in mostly less than 0.01% of your readers can be hackers and they can harm your website if you trusted them. Here, we are providing just 3 steps to safeguard/protect a php website.
"The most important security hole is safe_mode(), Never ever disable this in php settings"
1) Storing data in database
If you want to store data from users into database, always use addslashes() functions for every input. Users may add javascript code or iframe code in databases, so try to use strip_tags() function as well.
2) Printing Data
When ever you show data to user or output information, always user strip_tags() function and allow only div, p,br,strong,or font tags. Strip all other tags, otherwise, some user will insert malicious code in database and may iframe data or output javascript code
3) Session handling
Session hijacking is complex thing, and you must be worried about it if you have really serous website contents or user information. Otherwise, it’s not big thing. But when ever you let users to change password/change email or other information, ask them to re-enter old password. It will stop this problem of session hijacking.
If you want to store data from users into database, always use addslashes() functions for every input. Users may add javascript code or iframe code in databases, so try to use strip_tags() function as well.
2) Printing Data
When ever you show data to user or output information, always user strip_tags() function and allow only div, p,br,strong,or font tags. Strip all other tags, otherwise, some user will insert malicious code in database and may iframe data or output javascript code
3) Session handling
Session hijacking is complex thing, and you must be worried about it if you have really serous website contents or user information. Otherwise, it’s not big thing. But when ever you let users to change password/change email or other information, ask them to re-enter old password. It will stop this problem of session hijacking.
Don’t store sensitive information in cookies.
Well, just these 3 steps will keep your website from harm’s way. Oh i forgot, if you have admin section, password protect the admin directory. You can do it in cpanel or whatever control panel is provided by your hosting company because you never even tell the location of your safe in which your money rests !
URL rewriting in PHP
URL rewriting in PHP
URL rewriting is very essential technique for any website hosted on linux servers. Basically, it adds makeup to your urls and people find it easier to navigate and interested. Old fashioned urls likehttp://www.ab.com/comments.php?id=8&name=John&country=UK // it looks really complex
now with URL rewriting you could make this url like this
http//www.ab.com/comments/8/John/from/UK
Here is the best tool online to make SEO friendly URL rewrite online. After generate URL rewrite code for your website, save it to a new files as ".htaccess" and upload it to the root directory of your website
Online Tool for URL rewrite Code
|
Advantages/Benefits of URL RE-WRITING
URL rewriting is very good technique for seo but there are other advantages as well. Here are major advantages of using SEO FRIENDLY URLs
- Its easier for search engine to understand the contents of your website and it adds weight to SEO as well.
- It makes URL look great and users don't confuse in complex looking urls
- You can add different keywords to url rewrite for different modules which will show your website divided in proper blocks
- You can hide your target page from users by url writing. User will never know the real name of the web page.
- Programming technique and other important secrets can be kept hidden with it and users are provided with a beautiful fake urls
- It makes a websites grammatically more secure as hackers will have to try harder to get into website using simple injections or other techniques
How to swap two values without 3rd variable in PHP
How to swap values of two variables without using 3rd variable !
OK,
that's the most asked question when ever i went for an interview. Interviewer asks , can u swap values of two variables without taking 3rd variable ?
I mean, the simplest way to do this job is taking 3 variables
but the thing get tricky when we are asked to not to introduce 3rd variable at all. Here is the code to swap values between two variables without using/introducing 3rd variable, the most asked question in an interview for any kind of programming job !
This script is too small to get notice but it's quite complex and it tells a lot about programmer's logic and ability to solve complex problem.
Other important php job interview questions include
Top PHP interview Questions |
- Difference between require() , include() and include_once() functions
- What is GET & POST, what is difference between the two
- What are global functions in PHP?
- Is php Object oriented?
- Can we submit a form without a submit button
- Why we use hidden variables in forms ?
- How many ways are there to send a value from one page to another page.
- Session and cookies, which is safest and why ?
- What is php safe_mode()
- What is sql injection and how to prevent it ?
- How to get highest value in a column of database table.
- How to get second highest values in a column.
- How to define a constant in PHP
- Name the top 5 php functions we used most !
Thursday, 16 August 2012
Day 4/10 Fetching data from table - Learn PHP in 10 days
Fetching data from a table is pretty easier.
How to fetch data from mysql table
Here are the important stept- connect to mysql server
- select db name
- write sql to select data
- execute mysql_query() function
- save returned value in a variable/array
- read values from the array with foreach loop
Wednesday, 15 August 2012
Day 3/10 Php / MySQL - Learn PHP in 10 days
MySQL is an open source project just like PHP so that's why it has gained so popularity in such a short span of time.
There are Few stages when creating a php application which is going to interact with MySQL.
- You will need to know the mysql server username and password.
- You will need to know the mysql server URL / IP address
- You will need to know the database you will be handling/updating.
- Tell the PHP script about your mysql server and database
- Send a sql command to insert/update/delete data
- Send a sql command to retrieve data
- Manipulate the data according to user requirements
Important functions required to interact with a mysql server
- mysql_connect() - to create an active link to mysql server
- mysql_select_db() to select the database on a mysql server
- mysql_query() - to send a sql command to mysql server.
- mysql_close() - to close mysql server connection.
Let's connect to our DB in Vertrigo. After running vertrigo application go to
- Run vertrigo application
- go to http://localhost/phpmyadmin/
- create new database
- create new tables in database. // it must not be so tought
PHP script to connect to mysql server in vertrigo !
PHP script to insert data into mysql table!
PHP script to Delete data from mysql table!
Day 2/10 learn PHP in 10 days - PHP String and Array Functions
Today we are going to learn about strings and arrays in PHP. String and array functions are really handy in handling input and output data to manipulate it accordingly.
Some of the basic functions available in PHP to handle string are as under, We are not going to discuss anything in detail, you can try searching it online or see PHP manual.
Some Basic String Functions in PHP
Some of the basic functions available in PHP to handle string are as under, We are not going to discuss anything in detail, you can try searching it online or see PHP manual.
- str_replace() to find and replace data in a string
- strpos() find the position of the character/string within a string.
- ucwords() to make first letter capital
- strtolower() php function to lowercase the TEXT/STRING
- substr() find portion of a string.
- explode() This functions make pieces of a string with respect to any characters/string
Some Basic Array Functions in PHP
Here are some basic array manipulation functions in PHP- array() this is to create a new array like $names= array("name1","name2","name3");
- count() This functions returns number of entries in an array
- sort() sorts an array
- in_array() checks if a values is present in an array
Tuesday, 14 August 2012
Day 1/10 of learning PHP/MySQL in 10 days
OK, so leave extra things out of mind and focus on learning !
Today is first day with PHP and usually, everybody get confused and start feeling dizzy when trying to learn new things, well, that happens to most of us, because we are not adventurous while learning new thing is completely an adventure !
You will need two softwares to run your php program,
1st Sotware Needed is called Vertrigo Server" which we are going to use. Vertrigo is an application just like a linux server on Windows. So, i like linux so i am going to use it. However, you can use windows server or you can use XAMPP. The later is pretty good as well. I am choosing Vertrigo server becasue it's simple, free and problem free !
2nd Software / program is some sort of editor to create and update PHP files. Usually, Windows Notepad will work fine, but I would recommend to get adobe Dreamweaver as it will show you 90% of syntax errors etc. It's sort of great help to do programming in specific language in its own editor.
Click here to download vertrigo server free
Installation is pretty easy. Just run the setup. and If you are using windows system, Files will be saved under
C:\Program Files\VertrigoServ
our Working directory will be
C:\program files\VertrigoServ\www
Default Vertrigo Installation Directory |
WWW - The working Directory, All PHP files will be stored inside WWW directory to work ! |
You can change the default installation directory structure if you want to. That's no problem. After installing Vertrigo server, you have installed everything required to run and test a php program.
PHP Syntax
Php syntax is as follow
PHP Start and End tags. All Php codes must be inserted within both tags |
- Open Textpad / Notepad and create new file
- Now save the file with extension ".PHP" as test.php in C:\Progarm Files\VertrigoServ\www directory
- Write Start tags and End tags
- and write echo " My first output"; inside tags
- Open Your browser and write http://localhost/test.php
- But before that you must start Vertrigo server.
Vertrigo Server Startup Screen |
Learn PHP in 10 Days Online and FREE !
So do you want to learn PHP ??
Learn PHP Programming in 10 Days |
Background Required!
To understand PHP and be a php programmer, we consider that you already have programming / computer knowledge of some sort. Atleast a degree in college/school in computer science is required to understand the syntax and flow of php programs that will be introduced starting from next lecture.After reading 10 pages, you will be able to write a simple blog script in PHP, You will be able to add/delete posts and categories in admin section and people would be able to read it on your blog !
Complexity is Easy to Medium level, so if you are really new to PHP this is the best place for that !
Learn PHP in 10 days
Day 1 : Learn PHP in 10 days
- Download Required files/program to run a php/mysql script
- Configure server
- PHP syntax basics
- Run your first PHP Program
Day 2 : PHP String & Arrays
- PHP strings and String Functions
- PHP Arrays and array functions
Day 3 : PHP / MySQL
- PHP /MySQL Introduction
- Inserting Data and Deleting Data in PHP/mysql
Day 4 : Retrieving & deleting Data in PHP
- Getting data from Database and showing it on web page
- Updating data online
- PHP / Mysql Database Script Analysis
- Starting our First Blog application Development
- Adding and Deleting Categories
- Listing Database Categories
- Adding Posts and Showing Posts to users
- Deleting Posts
- Editing Posts
- Introduction to PHP Sessions
- Introduction to PHP Cookies
- PHP variables and global variables.
- Introduction to send data from one page to another page
Day 10 : Protecting PHP website
- PHP security basics
- PHP security functions
- Sql Injections and Form injuction preventions
Day 11 :
- More detailed talk about PHP programming
- Some really cool sources of PHP programs and scripts
- Some online website to read more about PHP Programming
Web Programming ? but which programming language ? and why PHP :)
The most important factor in choosing programming language for a project is it's dependencies. How big project is, how long and how big its going to be in next year. What are maximum number of users it can accept at a time. There are other factors, combine suggest the best programming language.
Currently, PHP is the best candidate for online programming language, it supports mysql database server which is free to use. From small, medium, big and very big to extra large online websites are being developed in PHP.
There are other candidates as well, like .net, java, and bla bla. However, php is the best as
If you want to learn php, you will have to stay with us bit longer as we going to introduce you with all new php tips / tricks and tutorials very soon !
Currently, PHP is the best candidate for online programming language, it supports mysql database server which is free to use. From small, medium, big and very big to extra large online websites are being developed in PHP.
PHP is like an elephant interms of what you can do with it (but it's not white elephant at all :)) |
- Its open source, MySQL is open source
- It uses the C like programming structure.
- It is object oriented and too simple to learn and understand !
- There are many frameworks available which are developed in PHP and help to develop an application within months or sometimes days in-case of very short application. Imagine " echo 'this is me'; How long did it take to print "this is me" in a php :)
- It has a secure future, so learn php now, it's not going anywhere
If you want to learn php, you will have to stay with us bit longer as we going to introduce you with all new php tips / tricks and tutorials very soon !
Friday, 10 August 2012
What is Programming
A program is a script / code which translate a user specifications into an output. If you want to do anything with a computer system, you will need to write a program for that special purpose. A computer, can't do anything on its own. You need a mastermind behind it, and usually, a programmer is that mastermind which instructs computer to give output.
Computer Programmer send instructions to computer via a computer program. For this, computer programmer must understand a language which computer understand, such a language is called a programming language.
So programming is callled a technique to send instructions to computer to get desired output.
Programming Language !
A programming language's definition according to wikipedia is
A programming language is divided into many categories however, we will not go into the details as this blog is dedicated to PHP, Ajax and Javascript only !
Computer Programmer send instructions to computer via a computer program. For this, computer programmer must understand a language which computer understand, such a language is called a programming language.
So programming is callled a technique to send instructions to computer to get desired output.
Programming Language !
A programming language's definition according to wikipedia is
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely.
A programming language is divided into many categories however, we will not go into the details as this blog is dedicated to PHP, Ajax and Javascript only !
Subscribe to:
Posts (Atom)