twitterfacebookgoogle plusrss feed

Pages

Friday, June 29, 2012

WampServer step by step

WampServer is a software allows you to create development environment using PHP, Apache Server, MySQL, phpMyAdmin and some other useful add-ons. It facilitates you to install and manage different versions of PHP, Apache Server and MySQL database under single roof. Download the current version from its official website i.e. http://www.wampserver.com/

Whole article is moved to WampServer - Tips and techniques

Which operating system suits you

This article is written for newbies, who are totally new for computer operating

As we all know, due to tough competition many companies has introduced their own operating systems. They present dozens of features and claims that their operating system is best for you. All these things makes you quite confuse.

Many students and friends asked me which operating system should be used.

Remember one thing that the function of the operating system is just to manage your computer hardware resource and provides you certain services which helps you to operate home and office works. Nearly all operating system offers these services, its up to you which really suits your requirements. Plus ... operating system depends on your hardware profile. So you should contact your software vendor to ask minimum hardware requirements for you.

One time my student asked, "Sir I searched every where but unable to find an operating system having a player like one you installed on your computer.", I laughed and replied, "My dear this software is not coming with any operating system, you have to download and install it directly from its website." So remember; operating system not facilitate you with all software you want; you have to get your desired software copy from media like disc or website.

If you are working at small office or just working at home; not a technical person you are and you don't care about little technical mishaps as well as your budget is low (cannot afford heavy and fast computer) and if your requirements are
  • preparing office documents, presentations, spreadsheets.
  • disc writing and printing.
  • using single computer (not working over network).
  • multimedia (songs, videos).
  • internet surfing (watching videos, checking emails, chatting, general web visits).
I suggest you to use Windows XP Home Edition (Microsoft announced that extended support for all the versions of Windows XP would end on April 8, 2014 and suggested that technical persons begin preparing to migrate to a newer OS), Window Vista Home Basic or Windows Vista Started. Additionally if you are working over shared network then Windows 2003 Server and Windows Vista Business will be best choices for you.

You may ask me by providing your system hardware profile so I will suggest you which operating system is best for you.

Multiple checkbox selection using JQuery


JQuery multiple checkbox selection is quite easy, simply put the following code and amend according to your choice

$("#maincheckbox").click(function() {
    $("input[type=checkbox]").attr("checked", this.checked);
});
 
$("input[rel=default]").click(function(){
    if($("input[rel=default]").length == $(".case:checked").length) {
        $("#maincheckbox").attr("checked", "checked");
    } else {
        $("#maincheckbox").removeAttr("checked");
    }
});


Wednesday, June 27, 2012

SQL Injection and user input


Many hacker try to temper sql queries which you are using while collecting data from your forms. If you are not formatting the data coming from public forms. Your own scripts may cause dangerous results including open access to your database and server access. 

Lets take a common example of user input for login forms.
While you are validating user to login; you commonly use following steps.

$user = $_POST["user_fld"];
$pass = $_POST["password_fld"];

SELECT * FROM tablename WHERE username = '$user' AND password = '$pass';

Now if you are not formatting your input, user may temper you above sql query by providing admin'; // or admin'; -- in username field. When processing by the server, your query will look like 

SELECT * FROM tablename WHERE username = 'admin'; //' AND password = '$pass';

In above case password checking is excluded from WHERE clause by commenting remaining part of the query. Now you know what this query means. It will allow user to login without providing a valid associated password.

This is the single example of sql injection, many others are available; if hacker is smart enough he or she may harm you valuable data.

So, what will be the solution? You may get rid of this serious problem if you format your incoming data by using PHP built-in functions or other user-defined functions.

I have developed a function written in PHP to override SQL Injection problem. You can download your copy from my github (https://github.com/adnnor/cleanX) repository.


Short form of if condition


Short form or Ternary operator is often used in many server and client side languages. The syntax of operator is usually same. I am going to give an example of PHP.

You are going to use an if condition in your PHP like

if ($country=="us")
   $language = "us english";
else
   $language = "uk english";

You may ternary oeprator to do same operation in short form; use following line of code

$language = ($country=="us")?"us english":"uk english";

is it cool ... isn't it :)

JQuery remove classes using wildcard

Normally you can remove class by giving its name like



$("element").removeClass("className");
 
... you can provide more than one class like 



$("element").removeClass("className otherClass thirdClass");
   but there is no built-in function in JQuery to remove classes using wildcards. 


you have three classes color-red, color-blue, color-green you want to remove all three classes without providing the name of all.


Try following technique



$("element").attr("class",
      function(pos, classes){
      return classes.replace(/\bbox-\S+/g, "");
});












Tuesday, June 26, 2012

Make your website popular

hi pal ...


Website popularity is the most important issue for every one who want to get stuck with cyber world. Many companies are offering you to make your website most popular or high rank in all search engines including Google Search Engine. Have you ever thought that by giving appropriate title, description or keywords will not make your website popular ... surprised? Yes i am right! Lets take a look to the following example;


(If you thinking about emag, articles or tutorials website)
A company XYZ is offering huge data with no cost to their visitors, this company build years before your website. On XYZ website an article with "How to make PHP Functions" is visited over millions of users/visitors. NOW THINK ... how your new website which is not established fully can be ranked high in the cyber market.


(If you are hanging with software downloading website)
Sorry to say but you are really a stupid if you are thinking about it ... dozens of licensed companies are working on it having experience of more than 10 years! For example you have software My world 1.0.2 on your website for download, same software is available on download.com. If user search for this software, ofcourse search engine will display the record of download.com not from your website. Hope you are a wise person and I think i should not give you any other example :)


Then what steps you should take to make your website popular.
  1. Search for unique content. software, making money, ezines or mags, tutorials, tips and tricks or website templates are not the only keywords which are served or searched by user. You must go beyond these topics. 
  2. Stay connected with social communities like blogger, facebook and twitter. Use APIs to facilitate your visitors. Keep posting on your blog, share on facebook, tweet on twitter to popularize you website. Don't use your name; use your website links/name. It will really help your website to grow.
  3. Using complex scripts take a lot of time. I suggest you, don't waste your time on heavy scripts and graphics to compete your website with other official website. I noticed that many newbies follow popular websites and try to copy them; like Google, twitter, Facebook, Adobe and Microsoft etc. Just concentrate on website content. Many visitors prefer webpage content to be displayed friendly. Javascript/JQuery float boxes, twitter like drop down login box, facebook like overlays, ajax and many other scripts will really confuse you. You can update your website once it established properly.
  4. If you plan to monetize your website; keep three things in your mind.
    a) Make your client believe that you primary objective is to provide clean and unique content. Earning should be your secondary objective. I suggest you to use Google Adsense or other quality Advertisers. If you follow all steps on this point you will be able to get approved Google Adsense account easily.
    b) Don't use popup advertisement banners. Its PITA, i personally don't like the websites having a lot of popup banners.
    c) If your content is unique and clear; you don't need to put too many advertisement banners. Just a single banner can earn much for you.
For now i have just these tips in mind. I will try to update this article time by time.

Wish you good luck :)

Sunday, June 24, 2012

Display Multidimensional Array

Many newbies don't know how to fetch all the keys and its values from the multidimensional arrays; it is as easy as 1, 2, 3 :) ... lets take a look at the following example

 array(
   "sencond_ele_arr_item1","sencond_ele_arr_item2","sencond_ele_arr_item3"
  ),
  "third_ele"   
  );


foreach($array as $value) {
 if (is_array($value)) {
  foreach($value as $dig_value) {
   echo "-->".$dig_value."
";
  }
 } else {
  echo $value."
";
 }
}


?>

This will be the out put
first_ele
-->sencond_ele_arr_item1
-->sencond_ele_arr_item2
-->sencond_ele_arr_item3
third_ele