Profile

Achievement

first submission:submitting first snipplet

apphp-snippets's Recent Snippets



« Prev 1 2 3
This example shows you how to restrict to a specific file or multiple files. Add the following code block and edit the file name/s according to yuor needs.
0 933 posted 6 years ago by apphp-snippets
This example shows you how to force www. or no-www. using .htaccess file.
0 949 posted 6 years ago by apphp-snippets
This snippet allows you to get random record from given table by weight. To run it, it must have a field named "weight". The more "weight" is assigned, the more often the record is selected. The value of "weight" should be an integer between 1 and 10...
0 883 posted 6 years ago by apphp-snippets
This snippet allows you to insert new record into table. In case a unique key already exists - it updates appropriate fields only, leaving other fields untouched.
0 907 posted 6 years ago by apphp-snippets
This example is a full HTML5 article structure. Just copy/paste it into your page to check.
0 1019 posted 6 years ago by apphp-snippets
To send data into iFrame you don't need JavaScript or anything. You just have the form's target attribute match the iframe's name attribute. The outer page doesn't even reload. Copy this code and test it.
0 1530 posted 6 years ago by apphp-snippets
If using transparency on a block element it makes the text inside transparent as well. Is there a way you can prevent that from happening? Yes, you may do it by putting the text in another div and setting the opacity to 100%, but that didn't do the j...
0 1007 posted 6 years ago by apphp-snippets
You may align background image not only to left or top corner, but also use an offset for alignment.
0 1058 posted 6 years ago by apphp-snippets
This snippet code allows you to prevent the viewer from being able to right-click on your page. This can discourage the average user from borrow images or code from your site.
0 873 posted 6 years ago by apphp-snippets
This code allows to calculate the full size of a directory using PHP.
0 926 posted 6 years ago by apphp-snippets
This code allows to perform a query to WhoIs service in PHP.
0 829 posted 6 years ago by apphp-snippets
This example shows you how to create redirection o another directory. It may be useful, for example, when you have a project, placed in sub-directory.
0 821 posted 8 years ago by apphp-snippets
The following code will display a cross-browser CSS-gradients. Th add the right selector you can use rgba() for transparency.
0 853 posted 8 years ago by apphp-snippets
It allows you to add your own fonts on the page. To convert to different formats use this service Font2Web.
0 874 posted 8 years ago by apphp-snippets
It allows you to add your own fonts on the page. To convert to different formats use this service Font2Web.
0 850 posted 8 years ago by apphp-snippets
You know that iFrames are a necessary evil for many of us. When yuo put a third party site in an iframe is always a risk because they can break out of that iframe and redirect the visitor to another location. This code acts as a defense for such case...
0 792 posted 8 years ago by apphp-snippets
Sometimes you may want to show the visitor that you are aware of their IP address. You can do so by using few lines of code as shown here. Place the code in any place of your page, where you want the IP address to appear:
0 825 posted 8 years ago by apphp-snippets
This example shows you how to log errors to a file, and prevent showing them to the user. Make sure that the file exists and you're able to write to it.
0 727 posted 9 years ago by apphp-snippets
Here you may find some useful snippets for calculating relative time for different purposes: to get info from a column within certain date, like the latest 7 days, to get time interval etc.
0 682 posted 9 years ago by apphp-snippets
The favicon is much normality in our days. Here the "apple-touch-icon" definition which is used when you save a bookmark to your home screen on an apple touch devices such as an iPad or iPhone. The interesting thing is that Android also supports its...
0 824 posted 9 years ago by apphp-snippets
This solution is based on Chrome specific CSS extension. Other browsers will ignore this rule.
0 798 posted 9 years ago by apphp-snippets
This example of code allows you to create a new object in javascript (using simple inheritance) such that the class of the object is defined from a variable. After creating the object you may use it for your purposes.
0 668 posted 9 years ago by apphp-snippets
Sometimes you may need to change image properties 'on-the-fly'. The best example is when you want to display blog post short description, retrieve the first image and try to turn it into the thumbnail: change some properties and add a special class n...
0 734 posted 9 years ago by apphp-snippets
This simple code demonstrates how to change automatically site language, according to the visitor's country. If you implement this script in your site it will open the page in the language of your visitor.
0 960 posted 9 years ago by apphp-snippets
This example shows you how to remove file extension from URLs using .htaccess file directives. Remember, that "mod_rewrite" works only on Apache server. Before trying please be sure that you are working on Apache server and the "mod_rewrite" module/e...
0 757 posted 10 years ago by apphp-snippets
We know that normally index.html or index.php is the default page for many servers, when visitor types a directory without specifying a file name. You can change this rule with .htaccess:
0 729 posted 10 years ago by apphp-snippets
MySQL has a handy and simple string function REPLACE() that allows table data with the matching string to be replaced by new string. This is useful if there is need to search and replace a text string which affects many records or rows, such as chang...
0 897 posted 10 years ago by apphp-snippets
This is a very simple snippet about how to create a database 1st, a user and then assign some privileges to the user to allow him/her to perform some specific actions like insert, create, update, select etc.
0 774 posted 10 years ago by apphp-snippets
To get button with line breaks you can use carriage return characters to break the line: &#x00A; or just <br> with a <button> tag:
0 1199 posted 10 years ago by apphp-snippets
The <!--> syntax is the HTML comment. This is the way to add your own notes into the code which will not display when the HTML is rendered by the browser. It is also a good practice for web-developers to use the comment tags to "hide" scripts from br...
0 2678 posted 10 years ago by apphp-snippets
« Prev 1 2 3