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

Sign Up Now To Get SEO and Programming Tips

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

Showing posts with label Download PHP Scripts. Show all posts
Showing posts with label Download PHP Scripts. Show all posts

Date List Static Array with PHP Function Drop Down

Date List Static Array with PHP Function Drop Down :

Date list static array can help you to design contact form in offline mood. With this code, you can add dates in your form without using API system.

 <?php   
      $date = array(   
      '1'=>'1',  
      '2'=>'2',  
      '3'=>'3',  
      '4'=>'4',  
      '5'=>'5',  
      '6'=>'6',  
      '7'=>'7',  
      '8'=>'8',  
      '9'=>'9',  
      '10'=>'10',  
      '11'=>'11',  
      '12'=>'12',  
      '13'=>'13',  
      '14'=>'14',  
      '15'=>'15',  
      '16'=>'16',  
      '17'=>'17',  
      '18'=>'18',  
      '19'=>'19',  
      '20'=>'20',  
      '21'=>'21',  
      '22'=>'22',  
      '23'=>'23',  
      '24'=>'24',  
      '25'=>'25',  
      '26'=>'26',  
      '27'=>'27',  
      '28'=>'28',  
      '29'=>'29',  
      '30'=>'30',  
      '31'=>'31');   
 ?>   
  <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="dates"><b>date:</b></label></div>   
        <div><select name="date" id="dates">   
                 <?php   
         foreach($date as $dates => $datenow)   
         {   
          echo'<option value="'.$dates.'">'.$datenow.'</option>';   
         }   
        ?>   
            </select>   
              </div>   
         </form>   
    </div>   
    </body>   
  </html>   

0 comments

PHP | Login Form | User Will Redirect According To Category

mysql database user category

Login Form Code As Category System:

Sometime you have to redirect user according to his category / position to specific page. So, here this login form code can help you. It is simple code and localhost tested.

 <?php  
  //header('location: index.php');  
  //session_start();  
 function confirm_query($data)  
      {  
           if(!$data)  
                die("Query Failed: " . mysqli_connect_error());       
      }  
 $username = $_POST['username'];  
 $password = $_POST['password'];  
 $host = "localhost";  
 $dbuser = "root";  
 $dbpass = "";  
 $db = "estate";  
      $con = mysqli_connect($host, $dbuser); //Connection with server  
      confirm_query($con);  
      $connection = mysqli_select_db($con, $db); //Database is connected here  
      confirm_query($connection);  
 if(isset($_POST['submit']))  
 {  
      $query = "SELECT * FROM users where username = '{$username}' and password = '{$password}';";  
      $all_users = mysqli_query($con, $query);  
      if(!$all_users)  
           echo 'user pass query not working;' . mysqli_connect_error();  
      $user = mysqli_fetch_array($all_users);  
      if(mysqli_num_rows($all_users) != 0)  
      {  
           if($username == $user[username] AND $password == $user[password])  
           {  
                if($user[Category] == "Receptionist")  
                {  
                     $_SESSION['username'] = $username;  
                     header("location: receptionist.html");  
                     exit;  
                }  
                //Example Like uncomment and change.   
                //make sessions and add code start_session(); in all pages start.  
                /*elseif($user[Category] == "Receptionist")  
                {  
                     $_SESSION['username'] = $username;  
                     header("location: receptionist.html");  
                     exit;  
                }*/  
           }  
      }  
 }  
 else  
 {  
      header("location: login.html");  
      exit;  
 }  
 ?>  

2 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
https://www.samijeweller.com.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

What is my IP address PHP Function? Simple Script

IP address PHP Function
IP address PHP Function

Now you can easily find IP address of user. You just need to put this bellow function to your PHP script. This is cool script to find IP address of user. check it

 function getipaddress()  
      {  
           if (!empty($_SERVER['HTTP_CLIENT_IP'])) {  
             $ip = $_SERVER['HTTP_CLIENT_IP'];  
           } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {  
             $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];  
           } else {  
             $ip = $_SERVER['REMOTE_ADDR'];  
           }  
           return $ip;  
      }  
If you are not familiar with function, and want to learn that how to create function. Visit it.
If you are trying to find more simple code for IP Address.  Use this code in your page anywhere.

 <?php  
 $ip=$_SERVER['REMOTE_ADDR'];  
 echo "<b>IP Address = $ip</b>";  
 ?>   
It will make you easy to detect user Internet Protocol Address. And you can locate your IP address easily.
4 comments
 
Copyright © 2013-2016. Samee Articles - All Rights Reserved
Proudly powered by Blogger