Posts

Showing posts from April, 2012

How to use Number Validation for text box onkeyup by javascript?

How to use Number Validation for text box onkeyup by javascript? i got stuck in this problem so i make some customize code of Number Validation for text box onkeyup by javascript. it runs good and give quick alert. you can copy and paste this code in your file and simply run the file and you can customize the code according to your need. <script type="text/javascript"> function checknum(s) { return (s.toString().search(/^-?[0-9.]+$/) == 0 ) } </script>  <input name="phone" id="phone" type="text" class="last_bg" onkeyup="if(this.value != '' &amp;&amp; !checknum(this.value)){this.value = ''; alert('Please enter numbers only!')}"  value=""/> Dont forget to add jquery.js file in this page

How to add 301 redirecting in url add www before the url?

Url rewriting in htaccess 310 for redirecting the url from website.com to www.website.com and you can use this code to add 301 redirect to your webiste to redirect the url from without www to www like http://website.com to http://www.website.com simple copy and paste this code in your htaccess file and replace the website word to your website name RewriteCond %{HTTP_HOST} ^website\.com$ [NC] RewriteRule ^(.*)$ http://www.website.com/$1 [R=301,L]

How to create a CSV file from MySQL with PHP?

Create a CSV file from MySQL with PHP simple copy and paste this code to create the csv file from mysql with php and change the query according to your need. <?php mysql_connect('host','username','password'); mysql_select_db('database_name'); function remove_char($var) { $set = preg_replace('/[^a-zA-Z0-9-+@() \.\_\']/','padh',trim($var)); return $set; } function csv_create() { header("Content-type: application/csv"); header("Content-Disposition: attachment; filename=".date('Y-m-d-h:i:s').".csv"); header("Pragma: no-cache"); header("Expires: 0"); $res = mysql_query("SELECT fname,lname,fullname,email FROM cs_users order by id"); echo "First Name,Last Name,Full Name,Email\n"; // fetch a row and write the column names out to the file while($val = mysql_fetch_array($res)) { $fname = remove_char($val['fname']); $lna

How to use linkedin login api in my php website?

If you want linkedin login api for your php website and use registration with linkedin then you came on right post. here is some code for your linkedin login follow the instruction as in this post and then You can easily apply this linkedin login in your website add this code in your header Make a linkedin image the name of that image should be linkedin.jpg and place this in your images folder this image will show on linekedin button <script language="javascript" type="text/javascript" src="/js/confirmed_custom.js" ></script> <script type="text/javascript" src="http://platform.linkedin.com/in.js">   api_key: your website likedin api        // HGYbaYgas6Hfa&   onLoad: onLinkedInLoad   authorize: false </script> <script type="text/javascript"> function onLinkedInLoad() { $('a[id*=li_ui_li_gen_]') .css({marginBottom:'20px'}) .html('<img src="images/lin

How to Send Mail using SMTP and PHP?

how to use  SMTP send mail script This article is all about " send Mail using SMTP and PHP ". so now you  can send your email SMTP authentication smtp and php script. each mail needed server authentication, So you have to buy mail server. First you have to make a php file and add this code in this file and file name should be  SMTPClass.php <?php class SMTPClient { function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body) { $this->SmtpServer = $SmtpServer; $this->SmtpUser = base64_encode ($SmtpUser); $this->SmtpPass = base64_encode ($SmtpPass); $this->from = $from; $this->to = $to; $this->subject = $subject; $this->body = $body; $this->newLine = "\r\n"; if ($SmtpPort == "") { $this->PortSMTP = 25; } else { $this->PortSMTP = $SmtpPort; } } function SendMail (){ if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP)) { fputs ($SMTPIN, &qu

How to add TimeStamp in wordpress like facebook and twitter?

How to add TimeStamp in wordpress like facebook and twitter? Simply copy and paste this code to use time stamp in wordpress you can also customize this time stamp code according to your need <?php $days = round((date('U') - get_the_time('U')) / (60*60*24)); if ($days==0) { echo "Posted today"; } elseif ($days==1) { echo "Posted yesterday"; } elseif ($days<8) { echo "Posted " . $days . " days ago"; } elseif($days<30) { $week = $days/7; echo "Posted " . round($week) . " weeks ago"; } else { $Month = $days/30; echo "Posted " . round($Month) . " months ago"; } ?>