In many HTML forms or content management systems the form element “SELECT” is used frequently. If you use your PHP code inside the standard HTML element the code will be nearly unreadable. Adding extra options is not really fun. This small handy function will produce a select menu based on an associative array. Just define an array and call the function, that’s all you need to do. Continue reading Create a dynamic select menu with PHP
Category: PHP code
Find on this website a number of PHP code snippets and custom functions. The code snippets will show you common functionality in PHP and MySQL packed mostly in functions or in easy to use and well commented code blocks. You’re welcome to post all your comments, suggestions and questions.
Find more tutorials on the Web Development Blog.
How to verify email addresses from your mailing list?
Email marketing is still one of the most efficient ways to reach your customer, leads and site followers. If your mailing list becomes older and hasn’t been used for some time, there is serious chance that some of the email addresses aren’t valid anymore.
Why do you need to verify these email addresses?
Some people would say, why should I care and there are people sending out their mailings to these invalid email addresses many times.Continue reading How to verify email addresses from your mailing list?
Alternative functions for file_get_contents()
Like many others I’ve used the native PHP function file_get_contents() to receive the content from a remote file because the functions is very easy to use. But is it the best way to do that? I see many scripts using that function and even WordPress plugins are using this function while WordPress has a native function to receive remote content.
While debugging some website, I’ve noticed that I get trouble using file_get_contents() if I use the 5G firewall rules for the remote site I tried to access. This native PHP function doesn’t send any USER AGENT information and that’s why a 5G rules has blocked the access. There are also other reasons to use other functions: Missing response codes, no option to add additional headers and limitations from your hosting provider are just a view of them. Continue reading Alternative functions for file_get_contents()
Prevent posting of long strings
You know the problem from weblog’s, forums and guestbook’s: Extra long strings with more than “x” same characters in order. The result is an element width which will distort your website. This function takes care of this kind of string (for example multiple chars or explanation marks). The formatted string is be shortened to the amount of characters you specify. Continue reading Prevent posting of long strings
Advanced PHP session start
If a session based web application is used by a visitor using Internet Explorer it’s possible that this user get some trouble. This will happen if parts of the application are accessed for example via a shortcut on the desktop and the application opens then in a new Explorer window. Continue reading Advanced PHP session start