PHP

Home/PHP

php code snippets, check valis email by php

22 02, 2013

Adding Google Adsense Vbulletin Mobile Style

If you want to put google adsense in Vbulletin Mobile Theme, go to your adsense account and choose ads for content. After that go to Styles and Templates, choose edit template from dropdown, choose 'Ad Location Templates'. Vbulletin 3.7 has 7 locations for  ads. The 7 locations are called: ad_footer_end ad_footer_start ad_forumdisplay_afterthreads ad_forumhome_afterforums ad_header_end ad_header_logo ad_navbar_below ad_showthread_beforeqr ad_showthread_firstpost Click to see the various ad locations available, find the one which is relavant to your ad and paste the google code in that template. You will see header template. Now you can put adsense code in it and wait for sometime for tha ads to become active. The ads do not show for some time usually. It might take 48hours max for the ads to show, so don't worry and wait. When ads are visible you can change their postion or color scheme as you wish.

18 02, 2013

Website RSS to Twitter (Posting to Twitter)

A lot of people would want to post  to twitter from their website. This means that the rss feed is tweeted to your twitter timeline. I will share a wonderful php script that can do it for you. Connecting your website with twitter is too easy now, using php you can post rss feed of your website to twitter. Check out the php code snippet given below and replace the values for your site and see how it works. // Set username and password $username = 'username'; $password = 'password'; // The message you want to send $message = 'is twittering from php using curl'; // The twitter API address $url = 'http://twitter.com/statuses/update.xml'; // Alternative JSON version // $url = 'http://twitter.com/statuses/update.json'; // Set up and execute the curl process $curl_handle = curl_init(); curl_setopt($curl_handle, CURLOPT_URL, "$url"); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl_handle, CURLOPT_POST, 1); curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$message"); curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password"); $buffer = curl_exec($curl_handle); curl_close($curl_handle); // check for success or failure if (empty($buffer)) { echo 'message'; } else { echo 'success'; } source: Posting to Twitter

27 02, 2012

Check Valid Email Using PHP

You can check if the email is valid or not by using regular experessions. Just copy and use the function below function is_valid_email($email) { if( preg_match("/[a-zA-Z0-9_-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+/", $email) > 0) return true; else return false; }