As years goes, so does the increase in SPAM on the web. Most users sign up on services with a fake E-Mail. They might even use other’s E-Mail for signing up. This is a big problem, because when you send an email to the signed up user, it goes to the wrong guy. So, you should verify user’s email before signing them up. You might think that it would cost database memory. Don’t worry, because my script won’t require storage of verification codes on database.
... [READ MORE]Posts marked with "Function" in tags
Image Handling On Client Side With Base64 In PHP
Every website needs images. It make the site attractive and beautiful. But sometimes, images won’t get loaded. The latest **Browsers **have a feature that generates image on a base64 string. Most of the browser have it. In this post I’m going to describe the way to use base64 in displaying images on a website.
What’s base64 ?
Base64 is a encrypting method which is available in many languages. It can be used for encrypting and decrypting. It is not like other hash functions (MD5, SHA 256, SHA 512). Unlike other hash methods, a base64 encrypted string can be directly decrypted. But other hash functions can only be used for checking a value.
... [READ MORE]Generating Random String in PHP
In PHP you can generate random number by using rand function, but there is no specific function to generate a random text or string. In this post I’m going to show the function that will generate a random string of length mentioned.
Here is the function:
function rand_string($length) {
$str="";
$chars = "subinsblogabcdefghijklmanopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$size = strlen($chars);
for($i = 0;$i < $length;$i++) {
$str .= $chars[rand(0,$size-1)];
}
return $str;
}
Usage
To generate a random string use rand_string() function with the parameter of length of the to be generated string. Here’s an example:
... [READ MORE]Add GET or POST parameters on include files in PHP
It’s not possible. But it is in a different way.
If you are adding GET parameters to file name like the following, then it won’t work:
The above code won’t load the file, because PHP Include function only looks for files, it won’t send any parameters. It will search for file.php?user=subin in the directory for the case above. You can make it work in a different way.
... [READ MORE]How to get Current Time and date in Javascript
function ctime(){
var currentdate = new Date();
var time=currentdate.getFullYear()+"-"+(currentdate.getMonth()+1)+"-"+currentdate.getDate()+" "+currentdate.getHours()+":"+currentdate.getMinutes()+":"+currentdate.getSeconds();
return time;
}
The best age calculation code in PHP
Here is the function :
function age($birthday){
... [READ MORE]
list($day,$month,$year) = explode("/",$birthday);
$year_diff = date("Y") – $year;
$month_diff = date("m") – $month;
$day_diff = date("d") – $day;
if ($day_diff < 0 && $month_diff==0){$year_diff–;}
if ($day_diff < 0 && $month_diff < 0){$year_diff–;}
return $year_diff;
}