Tuesday, August 20, 2013

What is Mail Cron?

Mail Cron:
Mail Cron is a UNIX command used for sending mails to customers at time intervals through SMTP's.
Cron Syntax:
/usr/bin/GET  http://your site or mail sending area complete path
Example:
/usr/bin/GET  http://www.naresh-php.com/index.php/mail/send_mails/mails_list

Keep Smileing...

Monday, August 12, 2013

How to display clock using Javascript in PHP?

The following snippet of code display current time in your web page.

JavaScript
 <script  type="text/javascript" >
   function updateClock () {
    var currentTime = new Date();
    var month = currentTime.getMonth();
    var date = currentTime.getDate();
    var year = currentTime.getFullYear();
    var currentHours = currentTime.getHours ();
    var currentMinutes = currentTime.getMinutes ();
    var currentSeconds = currentTime.getSeconds ();
   
    var months = new Array(
    "January", "February", "March", "April",
    "May", "June", "July", "August", "September",
    "October", "November", "December");
   
    // Pad the minutes and seconds with leading zeros, if required
    currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
    currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
   
    var currentTimeString = months[month]+" "+ date +", "+year+" "+currentHours + ":" + currentMinutes + ":" + currentSeconds;
   
    document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}
</script>

HTML Code
<body onload="updateClock(); setInterval('updateClock()', 1000 )">
<div id="clock" align="center" style="color:#F30; font-weight:100;">&nbsp;</div>
</body>


Have a nice day....

Simple captcha using jQuery in PHP?


PHP Code

$length = 6;
$captcha = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);


HTML Code

<input type="text" name="captcha" value="<?php echo $captcha; ?>"  id="captcha" />

Enter the code above here :

<input type="password" name="Enter Code" />

Can't read the image? click <a href='javascript: refreshCaptcha();'>here</a> to refresh</td>


JS Code

<script>
function refreshCaptcha()
{
 var text = '';
    var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

    for(var i=0; i < 6; i++)
    {
        text += possible.charAt(Math.floor(Math.random() * possible.length));
    }
    $("#captcha").change().val(text);
}
</script>


Keep Smileing...