Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Wednesday 20 April 2016

Browser Detection in PHP

Browser Detection in PHP

  1. <?php
  2. $ie = strpos($_SERVER["HTTP_USER_AGENT"], 'IE') ? true : false;
  3. $M_firefox = strpos($_SERVER["HTTP_USER_AGENT"], 'Firefox') ? true : false;
  4. $safari = strpos($_SERVER["HTTP_USER_AGENT"], 'Safari') ? true : false;
  5. $G_chrome = strpos($_SERVER["HTTP_USER_AGENT"], 'Chrome') ? true : false;
  6. ?>
//// Apply condtion for further Uses..../////
  1. <?php
  2. //Firefox
  3. if ($M_firefox) {
  4. echo 'you are using Firefox!';
  5. echo '<br />';
  6. }
  7. // Both(Safari or Chrome) use the same engine - webkit
  8. if ($safari || $G_chrome) {
  9. echo 'your browser is a webkit powered browser(Chrome Or Safari)';
  10. echo '<br />';
  11. }
  12. // IE
  13. if ($ie) {
  14. echo '<br>your browser is Internet Explorer<br>';
  15. echo '<br />';
  16. }
  17. // Not IE and for all other browsers
  18. if (!$ie) {
  19. echo '<br>your browser is not Internet Explorer<br>';
  20. echo '<br />';
  21. }
  22. ?>
If you like it , then don't forgot to share it!

Monday 4 April 2016

Establish connection with MySql Database through PHP.

Establish connection with MySql Database through PHP.

1) Select Database


  MySqli_connect("HostName","Username","Password","DatabaseName") // Recommended to use

                                                                 OR

  MySqli_connect("HostName","Username","Password","DatabaseName","Port","Socket")

2) Store above Connection line OR Object in a PHP Variable.


 $con=  MySqli_connect("HostName","UserName","MySql_Password","DatabaseName");

              // for Localhost:- HostName= Localhost, {also some hosting site like:- Microhost is                              //also use HostName as Localhost.}
              //                          Username= root, 
              //                          Password = Null,
              //                          Port=3306
              //                          Socket=Specifies the socket or named pipe to be used

3) Check whether the connection is established or Not !, For this use 'IF-ELSE' condition.


 if(!$con) // It is same as $con == 0 or $con != 1; or return FASLE. So query will stop here.
{
die("Not Connected");  // die Language Construct( Not a Function ) will  exits the current script.
                               //{ We always recommended that always use either ECHO or PRINTF and                                          // show/Handle an error Like:- Database is not connected at this time ..                                                 //Please try later..... So the whole script will running continue instead of                                                 //Breaks your whole  script. }
}
    echo "Database is connected with your PHP Web-Page"   ;
                           //Now there is not need to define any ELSE condition here because if 'IF'                                              // condition is not executed then content after closing of 'IF'  will be execute.

4) If point 3) is not execute then it mean your connection is established otherwise check your Connection Line or Parameter you write in point 1).

5) Now your connection from MySql Database is established, and in next Tutorial we will discuss about Retrieve information from MySql into the Web-Page.

Saturday 2 April 2016

No Right Click!


Protecting your Images
1. Disable Right Click on Images only
If you really must disable right-click, then limit the aggravation and use a script that disables it on images only (some scripts also prevent the IE6 image toolbar from appearing). Of course there will be times when people want to use right-click and have their mouse over an image, so I’d recommend you change the message slightly to reflect the fact that only images are affected.
But instead you can use :-
1) Normal coding which offer you save the Image:-
 try to right click to save this image
                                                 <img src="puppy.gif" alt="Puppy" />



2) Coding which 'Never' offer you save the Image:-  
try to right click to save this image
                          <img src="puppy.gif" alt="Puppy"  oncontextmenu="return false" />



3) Coding which 'Never' offer you save the Image also show 'Alert Box' :-  try to right click to save this image 
          <img src="puppy.gif" alt="Puppy"  oncontextmenu="alert('Hi Joe'); return false" />


You can also disable all images on the particular page by :- 
 Simply add the following code to the END of your page, right above the tag:
      <script>
document.oncontextmenu = function(e){
var target = (typeof e !="undefined")? e.target: event.srcElement
if (target.tagName == "img" || (target.tagName == 'a' && target.firstChild.tagName == 'img'))
return false
}
</script>

You can also disable all images on the particular page by :- 
Just replace your   <html>  to  <html onContextMenu="return false;">