For easy maintenance and viewing, I’m updating it in github.
For easy maintenance and viewing, I’m updating it in github.
When people share your page on facebook, you can set what image to be displayed together with your page description on facebook.
The code:
<meta property="og:image" content="http://yourdomain.com/path/to/image.jpg" />
References on FB
Easy way to forward using HTML files. Here’s the code
1 | <META HTTP-EQUIV="Refresh" CONTENT="0; URL=http://www.yourdomain.com"> |
Easiest way to create a printer friendly page is by creating another css file. What I did is just removing the heading style.
CSS (save the CSS file as style-print.css)
#header is id for your header (div or table)
1 2 3 | #header { display: none; } |
In HTML add this line
1 | <link rel="stylesheet" href="style-print.css" type="text/css" media="print" /> |
This is HTML frame code to cloak URL. Be careful when use it on affiliate program. Some program (like clickbank) don’t allow URL cloak with this method.
1 2 3 4 5 6 7 8 | <html><head> <title>example title</title> </head> <frameset border=0 rows="100%,*" frameborder="no"> <frame src="http://www.example.com" frameborder="no" border=0 noresize> <frame topmargin="0" marginwidth="0" scrolling="no" marginheight="0" frameborder="no" border="0" noresize> </frameset> </html> |
This code is used to replace line break saved in database to
in html display
$astring = str_replace(chr(13) . chr(10), "", $astring); |
Updated: Actually there is a built in function for this as follow
echo nl2br($astring); |
Check box handling is bit different compared to other form objects because it can receive multiple values. Here is the HTML code for the form
1 2 | <input name="fruit[]" type="checkbox" value="a" />Apple <input name="fruit[]" type="checkbox" value="o" />Orange |
and PHP code to handle the checkbox values.
1 2 3 4 5 6 7 8 9 | $fruit = $_POST['fruit']; if(!empty($fruit)) { foreach($fruit as $value) { $string = $value.','.$string; } $value = rtrim($value, ','); } |
This simple javascript code can be used to prompt user whether they want to proceed with an action or not. Usually be used when user click on delete or remove button/link.
The javascript code
1 2 3 4 5 6 7 8 9 10 11 12 | <script LANGUAGE="JavaScript"> <!-- function confirmSubmit() { var agree=confirm("Are you sure you want to DELETE this record?"); if (agree) return true ; else return false ; } // --> </script> |
The HTML code
1 | <a href="?act=delete&id=1234" onClick="return confirmSubmit()">Delete</a> |