Featured Post Today
print this page
Latest Post
Subscribe To Our Newsletter

Sign Up Now To Get Free Coupon Codes, Event Coupon Codes Updates, Offers Updates. It's 100% Free!

We Hate Spam! Really, It's terrible and we never do it.

Showing posts with label PHP Learning. Show all posts
Showing posts with label PHP Learning. Show all posts

PHP Brief Definition

PHP definition
PHP is a script language and interpreter that is freely available and used primarily on Linux Web servers. PHP, originally derived from Personal Home Page Tools, now stands for PHP: Hypertext Preprocessor, which the PHP FAQ describes as a "recursive acronym."
0 comments

Increase Max Execution Time With .htaccess file

Here I am going to write new shortcut, and I did research on it and gained that many people facing same problem that I faced.

Increase Max Execution Time:

There are many searching for it that how to increase max-execution-time of website. About billions of users are using CPanel and within Cpanel you are unable to change php.ini options. But if you have WHM or Root then you can do it easily but here we have to resolve this problem for our users. 
When you are using PHP module then it is confirm that you are using apache system too. apache system mostly works with .htaccess file so you can easily edit your .htaccess file and you can play with php.ini file without having WHM, WHMCS, Root, VPS, Dedicated server.

Requirements

But your system PHP language should be updated, minimum requirement is 5.x.
How can you find your PHP language version. 

Method:

Make a file name info.php and upload to your server like
domain.com/info.php
now open this and search
PHP Version
check max execution time. Search
max_execution_time
Increase Max Execution Time With .htaccess file:
Open .htaccess and add following code

<IfModule mod_php5.c>php_value max_execution_time 900</IfModule>
900 Is about 15 minutes. you can change it according to your mind.
thanks
0 comments

PHP | Detect User Browser Language

How to detect user browser language and how to use it in URL.
If you add this script above your file code.
Then url will be :
  • www.domain.com/index.php?lang=en
  • www.domain.com/index.php?lang=ar
  • www.domain.com/index.php?lang=es
  • www.domain.com/index.php?lang=fr
  • www.domain.com/index.php?lang=hu
  • www.domain.com/index.php?lang=ra
 Region wise. and you can use this to multilingual website.

 <?php  
 //Redirect by language  
 $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);  
 if(!isset($_GET['lang']))  
 {  
      //Retrieve location, set time  
      if(!isset($lang))  
      {  
           header("location: ".$_SERVER['PHP_SELF']);  
           exit;  
      }  
      else  
      {  
           header("location: ".$_SERVER['PHP_SELF']."?lang=".$lang);  
           exit;  
      }  
 }  
 ?>  

0 comments

Convert XML to PHP Array | Multilingual + Country wise SEO URL Solution

Multilingual + Country wise SEO URL Solution:

Example
http://www.getacho.com/index.php?loc=pk&lang=en
Here I did deep research that how can I use PHP for Multilingual websites?
But we need to keep in mind some topics like
  1. User IP Address Function
  2. User Language Function
  3. IP to XML
  4. XML to PHP Array Conversion
  5. URL Concept
  6. Language And Area codes concept
If you know these things then, you can use this function easily.

 <?php  
 //Redirect by language  
 $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);  
 $context = stream_context_create(array('http' => array('header' => 'Accept: application/xml')));  
 //redirect by IP  
 $_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];  
 $ip = $_SESSION['ip'];  
 $data = file_get_contents("http://api.hostip.info/get_html.php?ip=".$ip."&position=true");  
 $arrayofdata = explode("\n", $data);  
 $country = explode(":", $arrayofdata[0]);  
 $count = explode(" ", $country[1]);  
 if(!isset($_GET['lang']) AND !isset($_GET['loc']))  
 {  
      //Retrieve location, set time  
      if(empty($count))  
      {  
           header("location: index.php?loc=us-en&lang=".$lang);  
           exit;  
      }  
      else  
      {  
           header("location: index.php?loc=".strtolower(trim($count[2],"()"))."&lang=".$lang);  
           exit;  
      }  
 }  
 ?>  

0 comments

PHP | Website Validation Function

PHP Website Validation Function
function validate_web($input_web)
   {  
   $input_web = preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $input_web);
   $input_web = trim($input_web);  
            $input_web = htmlspecialchars($input_web);  
            $input_web = stripcslashes($input_web);
   return $input_web;
   }
0 comments

PHP | Email Validation Function

PHP Email Validation Function
function validate_email($input_email)
   {  
   $input_email = preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $input_email);
   $input_email = trim($input_email);  
            $input_email = htmlspecialchars($input_email);  
            $input_email = stripcslashes($input_email);
   return $input_email;
   }
0 comments

PHP | Name Validation Function

PHP Name Validation Function
function validate_name($input_name)
   {  
   $input_name = preg_match("/^[a-zA-Z ]*$/", $input_name);
   $input_name = trim($input_name);  
            $input_name = htmlspecialchars($input_name);  
            $input_name = stripcslashes($input_name);
   return $input_name;
   }
0 comments

PHP | Number Validation Function

PHP number validation function
function validate_number($input_number)
   {  
   $input_number = preg_match ("/^[0-9]*$/", $input_number);
   $input_number = trim($input_number);  
            $input_number = htmlspecialchars($input_number);  
            $input_number = stripcslashes($input_number);
   return $input_number;
   }
0 comments

PHP | Form Validation Function

PHP Form Validation Function for your site.
function validate_email($input_email)
   {  
   $input_email = preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $input_email);
   $input_email = trim($input_email);  
            $input_email = htmlspecialchars($input_email);  
            $input_email = stripcslashes($input_email);
   return $input_email;
   }
0 comments

PHP | How to destroy session?

PHP Session
On +Wizpert, Someone asked me that how to destroy session?
Session is used for specific purpose. like
  • Login user
  • Review creation
  • Forms Creation
  • Check Out system
  • And more
In this code you will learn, How to destroy session on logout click?


 <?php  
 $_SESSION = array(); // Oh Sorry here you need to null all sessions  
 setcookie(session_name(), '', time()-60); // here you will set cookies time back to age. like time()-60 mean . 1 minute before now.  
 session_destroy(); // here you will delete session  
 header("Location: login.php"); // here you will be reallocated to login.php page.  
 exit; // page code will be exit.  
 ?>  

I hope this can help you.
0 comments

PHP | Compare Arrays (Indexed Arrays, Associative Arrays, Multidimensional arrays)

PHP | Compare Arrays


 In Arrays lecture, I described about types of Array.
Types of Array in PHP

  1. Indexed arrays - Arrays with numeric index
  2. Associative arrays - Arrays with named keys
  3. Multidimensional arrays - Arrays containing one or more arrays
Here you will come to know that how to compare PHP arrays and how to fetch same value. Sometimes you have to get user detail and compare their attributes. 
Just like
  1. Reviews
  2. Top Contributors 
  3. Levels
  4. Addresses
  5. Cast
  6. Religion
  7. Country
  8. and more
And this question makes you confuse that how to compare and how to fetch same values with simple PHP functions.
The most important thing you need to understand
array_intersect
Concept. Array_Intersect is used to fetch same values between two arrays.
Here you will come to know, How to check arrays values for duplication?

Compare Arrays Code:

(Indexed Arrays, Associative Arrays, Multidimensional arrays)


 <?php  
      $array1 = array('Samee', 'Ullah', 'Feroz');  
      $array2 = array('SEO', 'SMO', 'PPC', 'Samee');  
      $campare = array_intersect($array1, $array2);  
      print_r($campare);  
      echo "<br />";  
      // => Output would be <=  
      // Array ( [0] => Samee )   
      $array1 = array('author' => 'Samee', 'Ullah', 'Feroz');  
      $array2 = array('SEO', 'SMO', 'PPC', 'worker' => 'Samee');  
      $campare = array_intersect($array1, $array2);  
      print_r($campare);  
      echo "<br />";  
      // => Output would be <=  
      // Array ( [author] => Samee )  
      $array1 = array('Samee', 'Ullah', array('Mohammad', 'Feroz', 'Din'));  
      $values = array_values($array1);  
      $array2 = array('SEO', 'SMO', 'PPC', 'Samee', 'Feroz');  
      foreach($values as $array)  
      {  
           $multiarray = array_intersect($array, $array2);  
      }  
      print_r($multiarray);  
      // => Output would be <=  
      // Array ( [1] => Feroz )  
 ?>  


Most Wanted Terms:
  1. php compare arrays
  2. php array compare
  3. php compare array
  4. php compare two arrays
  5. compare arrays php
  6. php compare array values
  7. php compare 2 arrays
  8. compare two arrays php
  9. array compare php
  10. php array of arrays
0 comments

How to use class="Active" in navigation, If you are using static pages?

navigation with URL
My Local Project for Getacho Company
I am working on my own company project. I am using Pixelogic static theme. I created different files for different website parts. like
  1. Menu.php
  2. Header.php
  3. Footer.php
Like it. But here I was facing a problem in class="active" Code. It was like

 <nav class="navigation">  
   <ul class="sf-menu" style="float:left;">  
     <li class="active"><a href="index.php">Home</a>  
     </li>  
     <li><a href="about.php">About</a></li>  
     <li><a href="portfolio.php">Portfolio</a>  
     <li><a href="forums/">Forums</a>  
     </li>  
     <li><a href="blog/">Blog</a>  
     </li>  
     <li><a href="contact.php">Contact</a>  
       <ul class="sub-menu main-ul">  
       <li><a href="support/">Support</a></li>  
       <li><a href="support/">Live Chat</a></li>  
       </ul>  
     </li>  
     <li><a href="user/">User Panel</a>  
       <ul class="sub-menu main-ul">  
       <li><a href="user/seo/">SEO Panel</a></li>  
       </ul>  
     </li>  
   </ul>  
 </nav>  

But here I was getting some problem that how to move class="active" according to static current page.
Then I consulted with my friends and someone suggested me a code. now it is working.

Code was :

 <?php  
      $url = $_SERVER['REQUEST_URI'];  
      if (strpos($url,'about.php') !== false)  
           echo 'class="active"';  
 ?>  

Here you need to understand STRPOS function.
I used same code in my navigation. Now navigation is working good. Now navigation code is

 <div id="menu" class="clearfix">  
   <nav class="navigation">  
     <ul class="sf-menu" style="float:left;">  
       <li   
       <?php   
       $url = $_SERVER['REQUEST_URI'];  
       if (strpos($url,'index.php') !== false)  
       {  
       echo 'class="active"';  
       }  
       ?>  
       ><a href="index.php">Home</a>  
       </li>  
       <li   
       <?php   
       $url = $_SERVER['REQUEST_URI'];  
       if (strpos($url,'about.php') !== false)  
       {  
       echo 'class="active"';  
       }  
       ?>  
       ><a href="about.php">About</a></li>  
       <li   
       <?php   
       $url = $_SERVER['REQUEST_URI'];  
       if (strpos($url,'portfolio.php') !== false)  
       {  
       echo 'class="active"';  
       }  
       ?>  
       ><a href="portfolio.php">Portfolio</a>  
       <li><a href="forums/">Forums</a>  
       </li>  
       <li><a href="blog/">Blog</a>  
       </li>  
       <li   
       <?php   
       $url = $_SERVER['REQUEST_URI'];  
       if (strpos($url,'contact.php') !== false)  
       {  
       echo 'class="active"';  
       }  
       ?>  
       ><a href="contact.php">Contact</a>  
         <ul class="sub-menu main-ul">  
         <li><a href="support/">Support</a></li>  
         <li><a href="support/">Live Chat</a></li>  
         </ul>  
       </li>  
       <li><a href="user/">User Panel</a>  
         <ul class="sub-menu main-ul">  
         <li><a href="user/seo/">SEO Panel</a></li>  
         </ul>  
       </li>  
     </ul>  
   </nav>  
 </div>  

Guidance by :  Nahyan Shiwani
4 comments

All Country List Static Array in PHP With Drop Down Option

All Countries List
County List
There are about 242 counties in this world. May be I also don't know all names. But as developer, we may need to add country list in registration form. You can get complete country list as static array from QWC. You just need to copy code and paste to your site. If you are beginner then you need to learn about ForEach Loop to understand this code.
Complete Country List Code is available below.
 <?php  
 $countrylist = array(  
      'AD' => 'Andorra',  
      'AE' => 'United Arab Emirates',  
      'AF' => 'Afghanistan',  
      'AG' => 'Antigua and Barbuda',  
      'AI' => 'Anguilla',  
      'AL' => 'Albania',  
      'AM' => 'Armenia',  
      'AN' => 'Netherlands Antilles',  
      'AO' => 'Angola',  
      'AQ' => 'Antarctica',  
      'AR' => 'Argentina',  
      'AS' => 'American Samoa',  
      'AT' => 'Austria',  
      'AU' => 'Australia',  
      'AW' => 'Aruba',  
      'AZ' => 'Azerbaijan',  
      'BA' => 'Bosnia and Herzegovina',  
      'BB' => 'Barbados',  
      'BD' => 'Bangladesh',  
      'BE' => 'Belgium',  
      'BF' => 'Burkina Faso',  
      'BG' => 'Bulgaria',  
      'BH' => 'Bahrain',  
      'BI' => 'Burundi',  
      'BJ' => 'Benin',  
      'BM' => 'Bermuda',  
      'BN' => 'Brunei Darrussalam',  
      'BO' => 'Bolivia',  
      'BR' => 'Brazil',  
      'BS' => 'Bahamas',  
      'BT' => 'Bhutan',  
      'BV' => 'Bouvet Island',  
      'BW' => 'Botswana',  
      'BY' => 'Belarus',  
      'BZ' => 'Belize',  
      'CA' => 'Canada',  
      'CC' => 'Cocos (keeling) Islands',  
      'CD' => "Congo, Democratic People's Republic",  
      'CF' => 'Central African Republic',  
      'CG' => 'Congo, Republic of',  
      'CH' => 'Switzerland',  
      'CI' => 'Cote D Ivoire',  
      'CK' => 'Cook Islands',  
      'CL' => 'Chile',  
      'CM' => 'Cameroon',  
      'CN' => 'China',  
      'CO' => 'Colombia',  
      'CR' => 'Costa Rica',  
      'CS' => 'Serbia and Montenegro',  
      'CU' => 'Cuba',  
      'CV' => 'Cap Verde',  
      'CS' => 'Christmas Island',  
      'CY' => 'Cyprus Island',  
      'CZ' => 'Czech Republic',  
      'DE' => 'Germany',  
      'DJ' => 'Djibouti',  
      'DK' => 'Denmark',  
      'DM' => 'Dominica',  
      'DO' => 'Dominican Republic',  
      'DZ' => 'Algeria',  
      'EC' => 'Ecuador',  
      'EE' => 'Estonia',  
      'EG' => 'Egypt',  
      'EH' => 'Western Sahara',  
      'ER' => 'Eritrea',  
      'ES' => 'Spain',  
      'ET' => 'Ethiopia',  
      'FI' => 'Finland',  
      'FJ' => 'Fiji',  
      'FK' => 'Falkland Islands (Malvina)',  
      'FM' => 'Micronesia, Federal State of',  
      'FO' => 'Faroe Islands',  
      'FR' => 'France',  
      'GA' => 'Gabon',  
      'GB' => 'United Kingdom (GB)',  
      'GD' => 'Grenada',  
      'GE' => 'Georgia',  
      'GF' => 'French Guiana',  
      'GG' => 'Guernsey',  
      'GH' => 'Ghana',  
      'GI' => 'Gibraltar',  
      'GL' => 'Greenland',  
      'GM' => 'Gambia',  
      'GN' => 'Guinea',  
      'GP' => 'Guadeloupe',  
      'GQ' => 'Equatorial Guinea',  
      'GR' => 'Greece',  
      'GS' => 'South Georgia',  
      'GT' => 'Guatemala',  
      'GU' => 'Guam',  
      'GW' => 'Guinea-Bissau',  
      'GY' => 'Guyana',  
      'HK' => 'Hong Kong',  
      'HM' => 'Heard and McDonald Islands',  
      'HN' => 'Honduras',  
      'HR' => 'Croatia/Hrvatska',  
      'HT' => 'Haiti',  
      'HU' => 'Hungary',  
      'ID' => 'Indonesia',  
      'IE' => 'Ireland',  
      'IL' => 'Israel',  
      'IM' => 'Isle of Man',  
      'IN' => 'India',  
      'IO' => 'British Indian Ocean Territory',  
      'IQ' => 'Iraq',  
      'IR' => 'Iran (Islamic Republic of)',  
      'IS' => 'Iceland',  
      'IT' => 'Italy',  
      'JE' => 'Jersey',  
      'JM' => 'Jamaica',  
      'JO' => 'Jordan',  
      'JP' => 'Japan',  
      'KE' => 'Kenya',  
      'KG' => 'Kyrgyzstan',  
      'KH' => 'Cambodia',  
      'KI' => 'Kiribati',  
      'KM' => 'Comoros',  
      'KN' => 'Saint Kitts and Nevis',  
      'KP' => "Korea, Democratic People's Republic",  
      'KR' => 'Korea, Republic of',  
      'KW' => 'Kuwait',  
      'KY' => 'Cayman Islands',  
      'KZ' => 'Kazakhstan',  
      'LA' => "Lao People's Democratic Republic",  
      'LB' => 'Lebanon',  
      'LC' => 'Saint Lucia',  
      'LI' => 'Liechtenstein',  
      'LK' => 'Sri Lanka',  
      'LR' => 'Liberia',  
      'LS' => 'Lesotho',  
      'LT' => 'Lithuania',  
      'LU' => 'Luxembourgh',  
      'LV' => 'Latvia',  
      'LY' => 'Libyan Arab Jamahiriya',  
      'MA' => 'Morocco',  
      'MC' => 'Monaco',  
      'MD' => 'Moldova, Republic of',  
      'MG' => 'Madagascar',  
      'MH' => 'Marshall Islands',  
      'MK' => 'Macedonia',  
      'ML' => 'Mali',  
      'MM' => 'Myanmar',  
      'MN' => 'Mongolia',  
      'MO' => 'Macau',  
      'MP' => 'Northern Mariana Islands',  
      'MQ' => 'Martinique',  
      'MR' => 'Mauritania',  
      'MS' => 'Montserrat',  
      'MT' => 'Malta',  
      'MU' => 'Mauritius',  
      'Mv' => 'Maldives',  
      'MW' => 'malawi',  
      'MX' => 'Mexico',  
      'MY' => 'Malaysia',  
      'MZ' => 'Mozambique',  
      'NA' => 'Namibia',  
      'NC' => 'New Caledonia',  
      'NE' => 'Niger',  
      'NF' => 'Norfolk Island',  
      'NG' => 'Nigeria',  
      'NI' => 'Nicaragua',  
      'NL' => 'Netherlands',  
      'NO' => 'Norway',  
      'NP' => 'Nepal',  
      'NR' => 'Nauru',  
      'NU' => 'Niue',  
      'NZ' => 'New Zealand',  
      'OM' => 'Oman',  
      'PA' => 'Panama',  
      'PE' => 'Peru',  
      'PF' => 'French Polynesia',  
      'PG' => 'papua New Guinea',  
      'PH' => 'Phillipines',  
      'PK' => 'Pakistan',  
      'PL' => 'Poland',  
      'PM' => 'St. Pierre and Miquelon',  
      'PN' => 'Pitcairn Island',  
      'PR' => 'Puerto Rico',  
      'PS' => 'Palestinian Territories',  
      'PT' => 'Portugal',  
      'PW' => 'Palau',  
      'PY' => 'Paraguay',  
      'QA' => 'Qatar',  
      'RE' => 'Reunion Island',  
      'RO' => 'Romania',  
      'RU' => 'Russian Federation',  
      'RW' => 'Rwanda',  
      'SA' => 'Saudi Arabia',  
      'SB' => 'Solomon Islands',  
      'SC' => 'Seychelles',  
      'SD' => 'Sudan',  
      'SE' => 'Sweden',  
      'SG' => 'Singapore',  
      'SH' => 'St. Helena',  
      'SI' => 'Slovenia',  
      'SJ' => 'Svalbard and Jan Mayen Islands',  
      'SK' => 'Slovak Republic',  
      'SL' => 'Sierra Leone',  
      'SM' => 'San Marino',  
      'SN' => 'Senegal',  
      'SO' => 'Somalia',  
      'SR' => 'Suriname',  
      'ST' => 'Sao Tome and Principe',  
      'SV' => 'El Salvador',  
      'SY' => 'Syrian Arab Republic',  
      'SZ' => 'Swaziland',  
      'TC' => 'Turks and Caicos Islands',  
      'TD' => 'Chad',  
      'TF' => 'French Southern Territories',  
      'TG' => 'Togo',  
      'TH' => 'Thailand',  
      'TJ' => 'Tajikistan',  
      'TK' => 'Tokelau',  
      'TM' => 'Turkmenistan',  
      'TN' => 'Tunisia',  
      'TO' => 'Tonga',  
      'TP' => 'East Timor',  
      'TR' => 'Turkey',  
      'TT' => 'Trinidad and Tobago',  
      'TV' => 'Tuvalu',  
      'TW' => 'Taiwan',  
      'TZ' => 'Tanzania',  
      'UA' => 'Ukraine',  
      'UG' => 'Uganda',  
      'UM' => 'US Minor Outlying Islands',  
      'US' => 'United States',  
      'UY' => 'Uruguay',  
      'UZ' => 'Uzbekistan',  
      'VA' => 'Holy See (City Vatican State)',  
      'VC' => 'Saint Vincent and the Grenadines',  
      'VE' => 'Venezuela',  
      'VG' => 'Virgin Islands (British)',  
      'VI' => 'Virgin Islands (USA)',  
      'VN' => 'Vietnam',  
      'VU' => 'Vanuatu',  
      'WF' => 'Wallis and Futuna Islands',  
      'WS' => 'Western Samoa',  
      'YE' => 'Yemen',  
      'YT' => 'Mayotte',  
      'YU' => 'Yugoslavia',  
      'ZA' => 'South Africa',  
      'ZM' => 'Zambia',  
      'ZW' => 'Zimbabwe'  
 ); ?>  
 <html lang="us-en" xml:lang="us-en">  
   <head>  
           <style>  
                .form{  
                     margin:10px auto;  
                }  
                .form label, select{  
                     display:inline-block;  
                     float:left;  
                }  
                .form label{  
                     width:100px;  
                }  
                .body{  
                     width:400px;  
                     height:50px;  
                     background-color:#C33;  
                     padding:20 20 20 20;  
                     margin:300px auto;  
                }  
     </style>  
   </head>  
   <body>  
        <div class="body">  
       <form class="form">  
            <div><label for="usstates"><b>Countries:</b></label></div>  
              <div><select name="states" id="usstates">  
                     <option>Select Country</option>  
                               <?php  
               foreach($countrylist as $countrycode => $countryname)  
               {  
                 echo'<option value="'.$countrycode.'">'.$countryname.'</option>';  
               }  
             ?>  
                      </select>  
                          </div>  
                </form>  
     </div>  
      </body>  
 </html>  

If you are from USA also get US States List code.
5 comments

US States List Static PHP Array with Drop Down Option

US States List in PHP
PHP States List Code Result

US States List with Static Array in PHP with Drop Down Option. You just need to copy it and add to your site. For this code, you just need to learn ForEach Loop in PHP.

US States Array List In PHP


 <?php  
 $usstates = array(  
   'AK' => 'Alaska',  
   'AZ' => 'Arizona',  
   'AR' => 'Arkansas',  
   'CA' => 'California',  
   'CO' => 'Colorado',  
   'CT' => 'Connecticut',  
   'DE' => 'Delaware',  
   'DC' => 'District of Columbia',  
   'FL' => 'Florida',  
   'GA' => 'Georgia',  
   'HI' => 'Hawaii',  
   'ID' => 'Idaho',  
   'IL' => 'Illinois',  
   'IN' => 'Indiana',  
   'IA' => 'Iowa',  
   'KS' => 'Kansas',  
   'KY' => 'Kentucky',  
   'LA' => 'Louisiana',  
   'ME' => 'Maine',  
   'MD' => 'Maryland',  
   'MA' => 'Massachusetts',  
   'MI' => 'Michigan',  
   'MN' => 'Minnesota',  
   'MS' => 'Mississippi',  
   'MO' => 'Missouri',  
   'MT' => 'Montana',  
   'NE' => 'Nebraska',  
   'NV' => 'Nevada',  
   'NH' => 'New Hampshire',  
   'NJ' => 'New Jersey',  
   'NM' => 'New Mexico',  
   'NY' => 'New York',  
   'NC' => 'North Carolina',  
   'ND' => 'North Dakota',  
   'OH' => 'Ohio',  
   'OK' => 'Oklahoma',  
   'OR' => 'Oregon',  
   'PA' => 'Pennsylvania',  
   'RI' => 'Rhode Island',  
   'SC' => 'South Carolina',  
   'SD' => 'South Dakota',  
   'TN' => 'Tennessee',  
   'TX' => 'Texas',  
   'UT' => 'Utah',  
   'VT' => 'Vermont',  
   'VA' => 'Virginia',  
   'WA' => 'Washington',  
   'WV' => 'West Virginia',  
   'WI' => 'Wisconsin',  
   'WY' => 'Wyoming');  
 ?>  
 <html lang="us-en" xml:lang="us-en">  
   <head>  
           <style>  
                .form{  
                     margin:10px auto;  
                }  
                .form label, select{  
                     display:inline-block;  
                     float:left;  
                }  
                .form label{  
                     width:75px;  
                }  
                .body{  
                     width:250px;  
                     height:50px;  
                     background-color:#C33;  
                     padding:20 20 20 20;  
                     margin:300px auto;  
                }  
     </style>  
   </head>  
   <body>  
        <div class="body">  
       <form class="form">  
            <div><label for="usstates"><b>States:</b></label></div>  
              <div><select name="states" id="usstates">  
                               <?php  
               foreach($usstates as $statcode => $statname)  
               {  
                 echo'<option value="'.$statcode.'">'.$statname.'</option>';  
               }  
             ?>  
                      </select>  
                          </div>  
                </form>  
     </div>  
      </body>  
 </html>  
0 comments

Simple Login Page And Its Code For Creating Sassion


Here you can create user sassion and detect Login Errors by this form. Easy and simple code for newbies.
 <?php session_start(); ?>  
 <?php require_once("includes/connection.php"); ?>  
 <?php  
      if(!isset($_SESSION['username']))  
      {  
           $error= array();  
           if(isset($_POST['submit']))  
           {  
                //Get values from form  
                $username = $_POST['username'];  
                $password = $_POST['password'];  
                $query = "select * from users where username = '" . mysql_real_escape_string($username) . "'";  
                $query_run = mysqli_query($connection, $query);  
                if(!$query_run)  
                     echo 'username, password query is not working well. <br />' . mysqli_connect_error();  
                if(mysqli_num_rows($query_run) != 0 )  
                {  
                     $user = mysqli_fetch_array($query_run);  
                     if($username == $user['username'])  
                     {                      
                          if($password == $user['password'])  
                          {  
                               $_SESSION['username'] = $username;  //User session is created here
                               header("Location: index.php");  
                               exit;  
                          }  
                          else  
                          {  
                               array_push($error, 'password Wrong');  
                          }  
                     }  
                     else  
                     {  
                          array_push($error, 'Username Wrong');  
                     }  
                }  
                else  
                {  
                     array_push($error, 'Login Error');  
                }  
           }  
      }  
      else  
      {  
           header('Location: signup.php');  
           exit;  
      }  
 ?>  
 <div align="left" style="float:right">  
 <h2 align="center">Login Panel for Developer</h2>  
 <form method="post" action="login.php">  
      <label for="username">Username: </label><input name="username" type="text" id="username" /><br />  
   <label for="password">Password: </label><input type="password" name="password" id="password" /><br />  
   <input type="submit" name="submit" value="Login" />  
 </form>  
 <?php  
      if(isset($_POST['submit']))  
                {  
                     echo $error[0];  
                }  
           ?>  
 </div>  

0 comments

Slug Create Function in PHP. URL Rewriting According to SEO Rules

SEO friendly Slug is very important in Search Engine Optimization. It is used to rewrite your URL as your title.
as if you write title: "My Name Is Sami" And if it is a page. Then
Its URL will be :
www.QWC.me/?page=1 [1 Is Page ID]

If you use title in URL it can be like it
www.QWC.me/?page=my20%name20%is20%sami

But if you use slug function: URL will be SEO friendly like

www.QWC.me/?page=my-name-is-sami

There are many function: I am going to add 2 good functions for it. there is no any personal PHP built in function.

1:
 function slug($str, $replace=array(), $delimiter='-')  
      {  
           if( !empty($replace) )  
      {  
           $str = str_replace((array)$replace, ' ', $str);  
      }  
           $clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str);  
           $clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean);  
           $clean = strtolower(trim($clean, '-'));  
           $clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean);  
           $clean = form_validation($clean);  
           return $clean;  
 }  


2:
 function slug2($string){  
   $slug=preg_replace('/[^A-Za-z0-9-]+/', '-', $string);  
   return $slug;  
 }  
0 comments

Get Row Data in Tables from MySQL

This small code is used by Pakistan Floor Mills. Here you can easily understand that how to show rows data from your database to your table in front end.
Use it and learn from it.

insert data form
This code will tell you how to get data from array and how to show in fields.
Setup a database connection with following code.
 -- phpMyAdmin SQL Dump  
 -- version 4.0.4  
 -- http://www.phpmyadmin.net  
 --  
 -- Host: localhost  
 -- Generation Time: Nov 12, 2013 at 06:49 PM  
 -- Server version: 5.6.12-log  
 -- PHP Version: 5.4.16  
 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";  
 SET time_zone = "+00:00";  
 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;  
 /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;  
 /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;  
 /*!40101 SET NAMES utf8 */;  
 --  
 -- Database: `asia`  
 --  
 -- --------------------------------------------------------  
 --  
 -- Table structure for table `test`  
 --  
 CREATE TABLE IF NOT EXISTS `test` (  
  `sno` int(4) NOT NULL,  
  `packing` varchar(20) NOT NULL,  
  `weight` int(4) NOT NULL  
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;  
 --  
 -- Dumping data for table `test`  
 --  
 INSERT INTO `test` (`sno`, `packing`, `weight`) VALUES  
 (1, 'Ghee 16 kgs', 16),  
 (2, 'Ghee 10 kgs', 10),  
 (3, 'Ghee 5 kgs', 5);  
 /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;  
 /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;  
 /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;  

phpmysql
See this SQL file Image
Get Row Data in Tables from MySQL
Now when you press this button results should be here. like that
code is here check it.

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>BROWSE DATA </title>

 <style type="text/css">
 
 html {
 overflow:auto;
 }
 
 body {
 background-color:#FFFFFF;
 margin:0 auto;
 }
 
  
 #mypopup2
 {
 float: left;
 width: 250px; height: 350px;
 background: #90bade; 
 border: 1px solid #069;
 text-align:center;
 padding:2px;
 margin-top:150px;
 margin-left:50px;
 overflow:auto;
 }
 
 
 #header
 {
 background-color:#3399FF;
 background-position:left center;
 line-height:25px;
 font-size:22px;
 color:#FFFF33;
 font-weight:600;
 border-bottom:1px solid #6699CC;
 padding:10px;
 }
 
 .design12 {
 background-image:url(Images/disk.png);
 background-position:left center;
 background-repeat:no-repeat;
 background-color:#FF9;
 border:1px solid #88de85;
 -webkit-border-radius:7px;
 -moz-border-radius:7px;
 font-size:15px;
 font-weight:700;
 font-family:verdana;
 color:#0d5f83;
 width:100px;
 cursor:hand;
 padding:9px;
 }
 
 .design13 {
 background-image:url(Images/reload_16.png);
 background-position:left center;
 background-repeat:no-repeat;
 background-color:#CF9;
 border:1px solid #88de85;
 -webkit-border-radius:7px;
 -moz-border-radius:7px;
 font-size:15px;
 font-family:verdana;
 font-weight:700;
 color:#0d5f83;
 width:100px;
 cursor:hand;
 padding:9px;
 }
 
 
 .txt
 {
 width:150px;
 font-family:Arial, Helvetica, sans-serif;
 font-size:14px;
 font-weight:300;
 }
 
 td
 {color:#6600CC;}
 
 </style>
    
    <!-- PHP Code START -->

<?php 

 if(isset($_POST['submit']))
 {
  // Connection variables 
  $host="localhost"; 
  $username="root"; 
  $password=""; 
  $db_name="asia";  
  
  // Connect to database 
  $con = mysqli_connect($host, $username, $password); 
  
  // Connect result 
  if(!$con)
  { 
   die('Error Connecting to Database: ' . mysqli_connect_error()); 
  } 
  
  // Database Selection 
  $sel = mysqli_select_db($con, $db_name); 
  
  // Database Selection result 
  if(!$sel)
  { 
   echo ('Error selecting Database: ' . mysqli_connect_error()); 
  } 

    $query  = 'select * from test';
      $result = mysqli_query($con, $query);
    $count = mysqli_num_rows($result);
    $row = mysqli_fetch_array($result);  
    
   if(!$result)
    echo 'select query error or data not found'; 

   }  
   else
   {
 $i = '';
 $count = '';
  $row = array('sno' => '', 'packing' => '', 'weight' => '');
   }
   ?>
 <!-- PHP Code END -->

 </head>
 
 <body>

 <div id="mypopup2" >
 <div id="header"><img src="Images/book_open.png" align="left">Browse Data</div>
 <div style="margin-top:10px;">

 <form name="form1" method="POST" action="#">
 
 <table border="1" cellpadding="1" cellspacing="1" bgcolor="silver" align="center" width="95%" >
    
 
 <th width="20%">Code</th>
 <th width="50%">Product</th>
 <th width="20%">Weight</th>
    <?php 
  if(isset($_POST['submit']))
  {
   $i = 1;
   while($i <= $count)
    {
       echo"<tr>";
     echo "<td>" . $row['sno'] . "</td>";
     echo "<td>" . $row['packing'] . "</td>";
     echo "<td>" . $row['weight'] . "</td>";
     echo "</tr>";
     $row = mysqli_fetch_array($result); 
     $i++;
    } 
  }


   echo "</table><br>";

 ?>
 </table>
 

 <div style="margin-top:125px;text-align:center;margin-top:100px;">
    <input type="submit" name="submit" value="Brow" class="design12">
 <input type="submit" name="button2" value="Clear" class="design13">
    </div>
 </form>
 </div>
 </div>
</body>
</html>

Result Output is :
Get Row Data in Tables from MySQL

Now it is your turn read this code, understand it and align it yourself by using great CSS skills.
0 comments

Echo Rules / Problems in PHP Language

Echo is used to show output results in PHP. But sometimes you get confuse for solving simple problems. like

How to add Conditional Statement within echo statement?
 It is wrong to use if conditional statement within echo statement. You should use ternary operator within echo statement. like
 echo '<li' . ($sel_subject == $subject['id']) ? 'class="selected"' : '' . '>';  

Can we use echo statement within echo statement?
No we can not use echo statement within echo statement. It is bad logic. 

Can we use echo with double or single quotes?
Yes; you can use  echo with double and single quotes like

 echo 'This is Quality Written Codes Blog';  
Output is : This is Quality Written Codes Blog

 echo "This is Quality Written Codes Blog";  
Output is : This is Quality Written Codes Blog

What is concatenation in echo statement? 
Concatenation is sued to connect two quotes blocks. like 

 echo "My Blog Name is " . "Quality Written Codes";  

" . " dot is used to add concatenation.

How to use backslash within echo?
There are two ways to use backslash within echo tag.

You can use single quote if you want to use backslash; like it

 echo 'This is Quality Written Codes Blog And My Name is \ Samee Ullah Feroz \';  
Its output is
This is Quality Written Codes Blog and My Name is \ Samee Ullah Feroz \

If you use double quotes for echo statement. then you need to remember this solutions.
  1. \/ => /
  2. \" => "
  3. \/\/ => //
 echo "This is \"Quality Written Codes\" Blog and my name is \\ Samee Ullah Feroz \\";  
Its output is 
This is Quality Written Codes Blog and My Name is \ Samee Ullah Feroz \

How to use Variables within and with echo?
You can use different methods for it. like 

 $blog = "Quality Written Codes";  
 echo "$blog";  
 echo '{$blog}'  
 echo $blog;  

Read More about it in our previous post : Display of Variables
0 comments

Online Database Creation PHP Code with SQL Contribution

Now you don't need to browse PHPMyAdmin for creating database user password by database wizard. You just need to upload this files on your server and create database automatically.

1st file is style sheet file. : stylesheet.css

 @charset "utf-8";  
 /* CSS Document for : http://www.QWC.Me */  
 #dbcreation{padding-left:30%; padding-right:30%; padding-top:10%; padding-bottom:20%;}  
 table{border-top-left-radius:25; border-top-right-radius:25;}  
 th{text-align:center; background-color:#999;}  
 table, th, td, tr, thead, tbody{padding: 10px;}  
 a{text-decoration:none;}  
 .error{color:red;}  
 #dbinstall{border:10; border-color:#999; border-top-left-radius:25; border-top-right-radius:25; border-bottom-left-radius:25; border-bottom-right-radius:25; padding-left:30%; padding-right:30%; padding-top:10%; padding-bottom:20%;}  
 #signupform{text-shadow:#999; padding-left:30%; padding-right:30%; padding-top:10%; padding-bottom:20%;}  

2nd file is Database Values Taken File : create_database.php

 <?php  
      session_start();  
 ?>  
 <!DOCTYPE html >  
 <html xmlns="http://www.w3.org/1999/xhtml" lang="us-en">  
 <head>  
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
 <link rel="stylesheet" href="css/stylesheet.css" />  
 <title>Database Creation Process</title>  
 </head>  
 <body>  
   <div id="dbcreation">  
     <table align="center">  
          <thead>  
            <tr><th colspan="2" align="center">Enter Database Detail</th></tr>  
       </thead>  
       <tbody>  
         <form action="install.php" method="post">  
         <tr><td><label id="host">Host: </label></td><td><input type="text" name="host" placeholder="i.e. locahost" required="required" /></td></tr>  
         <tr><td><label id="dbname">Database Name: </label></td><td><input type="text" name="dbname" required="required" /></td>  
         <tr><td><label id="dbuname">User Name: </label></td><td><input type="text" name="dbuname" placeholder="i.e. root" required="required" /></td>  
         <tr><td><label id="dbpass">Password: </label></td><td><input type="text" name="dbpass" required="required" /></td>  
         <tr><td colspan="2" align="center"><input type="submit" name="submit" Value="Create" required="required" /></td></tr>  
         </form>  
       </tbody>  
     </table>  
   </div>   
 </body>  
 </html>  


3rd file is Database installation file : install.php

 <?php  
      session_start();  
 ?>  
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
 <html xmlns="http://www.w3.org/1999/xhtml">  
 <head>  
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
 <link rel="stylesheet" href="css/stylesheet.css" />  
 <title>Database Installation Process</title>  
 </head>  
 <body>  
 <div id="dbinstall">  
   <?php       
                //Get values from create_database.php files  
                if(isset($_POST['submit']))  
                {  
                     echo '<form method="post">  
                     <input type="hidden" name="host" value="'.$_POST['host'].'">  
                     <input type="hidden" name="dbname" value="'.$_POST['dbname'].'">  
                     <input type="hidden" name="dbuname" value="'.$_POST['dbuname'].'">  
                     <input type="hidden" name="dbpass" value="'.$_POST['dbpass'].'">  
                     <input type="submit" name="install" value="Install" align="center">  
                     </form><br/>';   
                     echo 'Welcome to installation process....<br/>  
                     Click install Button to install database.....<br />';  
                }                 
                //if user click on install button then install database on site  
                if(isset($_POST['install']))  
                {            
                     $dbhost = $_POST['host'];  
                     $dbname = $_POST['dbname'];  
                     $dbuname = $_POST['dbuname'];  
                     $dbpass = $_POST['dbpass'];  
                     //connect to mysql server for connecting server : need to give local host and user name  
                     $connect = mysqli_connect($dbhost, 'root');                 
                     //database creation.   
                     $db_create_query = "Create database " . $dbname;  
                     $database = mysqli_query($connect, $db_create_query);  
                     //database creation query error show  
                     if(!isset($database))  
                          {  
                               die("<div class=\"error\">Database creation query error : " . mysqli_connect_error() . "</div>");  
                          }  
                     //database users password query creation  
                     $dbuserpass = "create user " . $dbuname."@".$dbhost. " identified by '".$dbpass."'";  
                     $dbuserpass2 = mysqli_query($connect, $dbuserpass);  
                     //database users password query Error  
                     if(!isset($dbuserpass2))  
                          {  
                               die("<div class=\"error\">Database Username Password query error : " . mysqli_connect_error() . "</div>");  
                          }  
                     //give grant privileges to database user pass  
                     $previleges = "GRANT ALL PRIVILEGES ON $dbname. * TO '$dbuname'@'$dbpass' WITH GRANT OPTION";  
                     $previleges2 = mysqli_query($connect, $previleges);  
                     //check previleges error  
                     if(!isset($previleges2))  
                          {  
                               die("<div class=\"error\">Database Username Password query error : " . mysqli_connect_error() . "</div>");  
                          }                      
                     else  
                          {  
                               echo "Database has been created successfully<br />  
                                         Database Name :" . $dbname. "<br /> Database User Name : ".$dbuname."<br /> Database Password : ".$dbpass;  
                          }  
                }  
                session_destroy();  
      ?>  
 </div>  
 </body>  
 </html>  


I hope you will learn from it. copy code and check it

1 comments

Complete Self Controlled Form : Full Validations and Features with $_POST[] Method

According to new research, many hackers are working together to hack many sites. Now everyone is familiar with PHP, xHTML, CSS working and they can hack your form by
  • Save page as
  • Code checking
  • Firebug tool
  • Ctrl+U
So you need to make your contact form secure to safe your information..
I made this form to make your site more secure.
This form consists on some parts:
  1. Validate Function
  2. Values Validating
  3. Characters Limit Error Message
  4. Left Field Error Message
  5. Auto Selected fields after redirection
  6. CSS
  7. Form Fields
  8. Form Results
  9. Form Error Message
This form is divided into parts, anyone can easily understand it.
In this form : characters limit is
 'name' => 20, 'number' => 16, 'email' => 35,'subject' => 50, 'message' => 350, 'website' => 50

You can change it according to yourself.


  <?php  
           #######################################  
           #   Form Validation Function Start    #  
           #######################################  
      function form_validation($input)  
      {  
           $input = trim($input);  
           $input = htmlspecialchars($input);  
           $input = stripcslashes($input);  
           return $input;  
      }
   function validate_number($input_number)
   {  
   $input_number = preg_match ("/^[0-9]*$/", $input_number);
   $input_number = trim($input_number);  
            $input_number = htmlspecialchars($input_number);  
            $input_number = stripcslashes($input_number);
   return $input_number;
   }
   function validate_name($input_name)
   {  
   $input_name = preg_match("/^[a-zA-Z ]*$/", $input_name);
   $input_name = trim($input_name);  
            $input_name = htmlspecialchars($input_name);  
            $input_name = stripcslashes($input_name);
   return $input_name;
   }
   function validate_email($input_email)
   {  
   $input_email = preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $input_email);
   $input_email = trim($input_email);  
            $input_email = htmlspecialchars($input_email);  
            $input_email = stripcslashes($input_email);
   return $input_email;
   }
   function validate_web($input_web)
   {  
   $input_web = preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $input_web);
   $input_web = trim($input_web);  
            $input_web = htmlspecialchars($input_web);  
            $input_web = stripcslashes($input_web);
   return $input_web;
   }
   
           ######################################  
           #   Form Validation Function end     #  
           ######################################  
 /*--------------------------------------------------------------------------------*/  
           ####################################################
           #   Getting All Values and Validating them Start   #  
           ####################################################
                $error_msg = ""; //this variable for error massage  
    $departments = array(); //this array for saving department
                $name = $number = $email = $birth = $gender = $subject = $website = $select = $message = $color = ''; // we show all variables empty  
           ###############################################################  
           #   Submit Button Processing with secure validation Start     #  
           ###############################################################                      
                
    if(isset($_POST['submit']))  
                {  
                     $fields = array('name', 'number', 'email', 'birth', 'gender', 'departments', 'select', 'website', 'subject', 'message', 'color'); // all values field array  
      $errors = array(); //this array for saving errors 
                     foreach ($fields as $field) //this is for getting values  
                     {  
                          if(!isset($_POST[$field]) || $_POST[$field] == '' && $field != 'color') //if field value is empty or has nothing  
                          {  
                               array_push($errors, $field); //then selective field array value will be saved in error array.  
                          }  
                          else //if submit button has run, then it else will run  
                          {  
                               if($field != 'departments') //but if value is other than department field  
                               {  
                                    $$field = form_validation($_POST[$field]); //It will go through user define function and value will be made variables  
                               }  
                               elseif($field == 'departments') //but if value is about department then  
                               {  
                                    $departments = array(); //we define an array to save department values  
                                    $test_dept = $_POST[$field]; //we get department here  
                                    foreach($test_dept as $dept ) //we used departments parameter to save that on dept  
                                    {  
                                         array_push($departments, form_validation($dept)); //department will be fully validate and saved to department array  
                                    }  
                               }
                          }
        if($field == 'select' && $_POST[$field] == 'Navigation')
        {
         !array_push($errors, form_validation($field));
        }
                     } //this is foreach loop end  
                ##################################################  
                #   Getting All Values and Validating them end   #  
                ##################################################  
                ###########################################################################  
                # If No Error than Check characters Limit and show exceed Massage Start   #  
                ###########################################################################           
                          //As we have saved error values in errors array  
                     if(empty($errors) || !empty($errors))  
                     {  
                          //we define a assosiative array to define characters limit  
                          $fields = array('name' => 20, 'number' => 16, 'email' => 35,'subject' => 50, 'message' => 350, 'website' => 50);   
                          //For checking lenght we need to add a loop  
                          foreach($fields as $field => $length) //foreach loop is used for arrays : $field => $length we used for assosiative array  
                          ## in this $field => $length : $length variable as assigned to values  
                          {  
                               if (strlen($_POST[$field]) > $length)  
                               {  
                                    array_push($errors, $field . ' field characters limit has exceeded.'); //we shall use $field variable here,   
                                    # Because we are not using $fields, we are using $field as referance.   
                               }
          if($field == 'number' && !validate_number(($_POST[$field]))) //it is to validate number field.
          {
           array_push($errors, $field . " is not proper number."); //if there is an error in number field , error would be push on error array
          }
          if($field == 'name' && !validate_name(($_POST[$field]))) //it is to validate number field.
          {
           array_push($errors, $field . " is not proper name."); //if there is an error in number field , error would be push on error array
          }
          if($field == 'email' && !validate_email(($_POST[$field])) && !empty($_POST[$field])) //it is to validate number field.
          {
           array_push($errors, $field . " is not proper email."); //if there is an error in number field , error would be push on error array
          } 
          if($field == 'website' && !validate_web(($_POST[$field])) && !empty($_POST[$field])) //it is to validate number field.
          {
           array_push($errors, $field . " is not proper website link."); //if there is an error in number field , error would be push on error array
          } 
                          }  
                     } //it is if emtpy end  
                ########################################################################## 
                # If No Error than Check characters Limit and show exceed Massage End    #  
                ##########################################################################      
                ##################################################### 
                # If Error than then show the errors fields start   #  
                ##################################################### 
                     if(!empty($errors))  
                     {  
                          $error_msg = '<b>There are errors in following fields:</b> <br />';  
                          $error_msg .= implode('<br />', $errors);   
                     } //it is if not empty end  
                #########################################################  
                # If Error than then show the errors fields end         #  
                #########################################################  
                } //if isset POST['submit'] end  
           ###############################################################  
           #   Submit Button Processing with secure validation End       #  
           ###############################################################                      
 ?>  
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
 <html xmlns="http://www.w3.org/1999/xhtml" lang="us-en">  
 <head>  
 <title><?php $pagetitle="Self Controlled Form : Full Contact Form Feachers : Samee Ullah Feroz";
      define("blogname","www.QWC.me");
     echo $pagetitle ." : ". blogname; ?></title>
               <meta name="description" content="<?php echo $pagetitle ?> : Buy it." />
               <link rel="icon" type="image/ico" href="http://www.iconarchive.com/download/i50954/deleket/3d-cartoon-vol3/Web-Coding.ico" alt="Icon" />

      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<style>
/*html
    {
        height:100%;
        width:100%;
        background:url(http://www.southsoft.co.za/images/mysql.jpg) center center no-repeat;
        background-position:center;
 You can also give local file path
    }*/
a:link 
    {
        color:#00F;
        text-decoration:none;
    }

body
    {
  color:#0000FF;
  font-family:"Courier New", Courier, monospace;
  /*background-image:url(http://www.getacho.com/download/phpcss/images/bg-color.png);
  background-repeat:repeat;
  background-attachment:fixed;*/
    }
    
 
#main
 {
  color: #0000FF;
  overflow: auto;
  padding: 10px;
  width: 100%;
 }
 
ul
 {
  
  list-style:square url("images/sqpurple.gif");
 }
#table_bg   
 {  
   border:0;  
   border-color:#000;   
      border-collapse:separate;  
   padding:3;
   padding-right:100px;
 }
.sidemsg  
 {  
      margin-top:60px;
   font-family:"Courier New", Courier, monospace;  
      font-size:16px;  
 }  

</style>               
 </head>  
 <body style="background-color:<?php echo $color?>; ">  
           <div id="main">
           <h1 align="center">Secure Self Controlled Contact Form.</h1> 
           <h2>Qualities</h2>
           <ul>
           <li>Secure from Hackers</li>
           <li>Fast Processing</li>
           <li>Single File Contact Form</li>
           <li>Show Error on characters limit exceeded</li>
           <li>Show Error on Wrong Name</li>
           <li>Show Error on Wrong Email</li>
           <li>Show Error on Wrong Website</li>
           <li>Show Error on Wrong number</li>
           <li>Numbers only digits not doubles</li>
           <li>Cannot select future date of birth</li>
           <li>Can select background custom color</li>
           <li>Can select required Department</li>
           <li>Can select required Agent</li>
           <li>HTML, Javascript etc. Don't work</li>
           <li>After getting errors, form will not reset</li>
           </ul>
           <blockquote>This form is coded to keep away your site from <b>Hackers</b>.</blockquote>
           <h2>Price</h2>
           <hp>You can purchase this form in 5$ just.</hp> 
           <b>Samee is Online On</b><br />
           <b>Company Site : </b><a href="http://www.getacho.com" target="_blank">Getacho Company</a><br />
           <b>Facebook : </b><a href="http://www.facebook.com/sameeullah.feroz" target="_blank">Samee Ullah Feroz</a><br />
           <b>Gtalk :</b> <a href="mailto:seo.getacho@gmail.com" target="_blank">SEO.Getacho</a><br />
           <b>Skype : </b><a href="skype:SEO.Getacho?call">SEO.Getacho</a><br />
           
           </div>
           <div id="table_bg">
               <table style="background-color:<?php echo $color?>; width: 100%;" align="center" >  
               <form action="self_controlled_form.php" method="post" >  
                    <tr><td><label for="name"><strong>Full Name:</strong></label></td>  
                    <td><input type="text" name="name" placeholder="Full Name" style="width:250px;" value="<?php echo $name;?>" /></td></tr>  
                    <tr><td><label for="number"><strong>Personal Number:</strong></label></td>  
                    <td><input type="text" name="number" placeholder="00923234223945" style="width:250px;" value="<?php echo $number;?>"/></td></tr>  
                    <tr><td><label for="email"><strong>Email:</strong></label></td>  
                    <td><input type="text" name="email" placeholder="i.e. mail@example.com" style="width:250px;" value="<?php echo $email;?>"/></td></tr> 
                    <tr><td><label for="website"><strong>Website:</strong></label></td>                   
                    <td><input type="text" name="website" placeholder="i.e. www.example.com" style="width:250px;" value="<?php echo $website;?>"/></td></tr                
                    ><tr><td><label for="gender"><strong>Your Gender:</strong></label></td>  
                    <td><input type="radio" name="gender" value="Male"   
                    <?php if($gender == 'Male' && !empty($gender))echo 'checked';?>/>Male  
                    <input type="radio" name="gender" value="Female"   
                    <?php if($gender == 'Female' && !empty($gender))echo 'checked';?>/>Female</td></tr>
                    <tr><td><label for="birth"><strong>Your DOB:</strong></label></td>                  
                    <td><input type="date" name="birth" value="<?php echo $birth;?>" max="<?php echo date();?>" min="1991-01-01" /></td></tr>  
                    <tr><td><label for="departments[]"><strong>Contact Departments:</strong></label></td>  
                    <td><input type="checkbox" name="departments[]" value="Marketing Department"   
                    <?php if(in_array('Marketing Department', $departments)&& !empty($departments))echo 'checked';?>/>Marketing Department <br /> 
                    <input type="checkbox" name="departments[]" value="Development Department"   
                    <?php if(in_array('Development Department',$departments)&& !empty($departments))echo 'checked';?>/>Development Department <br /> 
                   <input type="checkbox" name="departments[]" value="Finance Department"   
                    <?php if(in_array('Finance Department', $departments) && !empty($departments))echo 'checked';?>/>Finance Department </td></tr>  
             <tr><td><label for="select"><strong>Contact Agent:</strong></label></td>  
                    <td><select name="select">
                        <option value="Navigation">Navigation</option>
                           <option value="Online Agent" <?php if($select == 'Online Agent' && !empty($select))echo 'selected'; ?> >Online Agent</option>  
                           <option value="SEO, SMO Agent" <?php if($select == 'SEO, SMO Agent' && !empty($select))echo 'selected'; ?> >SEO, SMO Agent</option>  
                           <option value="SEM, SMM Agent" <?php if($select == 'SEM, SMM Agent' && !empty($select))echo 'selected'; ?> >SEM, SMM Agent</option>  
                           <option value="Development Agent" <?php if($select == 'Development Agent' && !empty($select))echo 'selected'; ?> >Development Agent</option>  
                           <option value="Consultancy Agent" <?php if($select == 'Consultancy Agent' && !empty($select))echo 'selected'; ?> >Consultancy Agent</option>  
                           <option value="HR Agent" <?php if($select == 'HR Agent' && !empty($select))echo 'selected'; ?> >HR Agent</option>  
                    </select></td></tr>  
                    <tr><td><label for="subject"><strong>Subject:</strong></label></td>  
                    <td><input type="text" name="subject" placeholder="Type Subject" style="width:250px;" value="<?php echo $subject;?>"/></td></tr>  
                    <tr><td valign="top" align="left"><label for="message"><strong>Your Message:</strong></label></td>  
                    <td><textarea cols="40" rows="10" name="message" placeholder="Write your message"><?php echo $message;?></textarea></td></td>  
                    <tr><td valign="top" align="right"><input type="submit" value="Send" name="submit" /></td>  
                    <td>Choose the color :<input type="color" name="color" value="<?php echo $color; ?>" />
                    <br />This Feature Works on Chrome.
                    <br />Developed by <a href="mailto:sam@qwc.me">Samee Ullah Feroz</a><br /> Powered by : <a href="http://www.qwc.me">QWC.Me</a></td></tr>  
               </form>  
               </table>
               </div>
             <div class="sidemsg" style="background-color:<?php echo $color?>; ">  
            <h2>Results Here</h2>
             <?php  
                   echo $name . "<br />";  
                   echo $number . "<br />";  
                   echo $email . "<br />";
       echo $website . "<br />";  
                   echo $gender . "<br />";
                   echo $birth . "<br />";  
                   if (!empty($departments))
                   {
                       echo implode("<br />", $departments) . "<br />";
                   }
                   echo $select . "<br />";  
                   echo $subject . "<br />";            
                   echo $message . "<br />";  
                   echo $error_msg . "<br />";
                   ?>  
             </div>
 </body>  
 </html>

Form is complete with full security and limitations.

Instructions : This code is in-complete if you need this form, contact Samee Ullah Feroz

Demo : 
Ask For Installation
Consultant: 
On Facebook
Gtalk : SEO.Getacho@gmail.com
Skype : SEO.Getacho


0 comments
 
Support : | Internet Marketing Specialist And Business Developer
Copyright © 2013-2016. Samee Articles - All Rights Reserved
Proudly powered by Blogger