Home

Friday, December 30, 2011

PHP Captcha

Step-1 Captcha.php

<?php
session_start();
$num='';
$string = "abcdefghijklmnopqrstuvwxyz0123456789";

for($i=0;$i<7;$i++){
    $num1=rand(0,35);
    $num .= $string{$num1};
}

$_SESSION["num1"]=$num;
$img=imagecreate(90,27);
$color=imagecolorallocate($img,255,255,255);
$color1=imagecolorallocate($img,0,0,0);
imagestring($img,5,10,10,$num,30);
$fontsize=20;
$fontcolor = imagecolorallocate($img, 0, 0, 0);
$x = 0;
$y = $fontsize;

header('Content-type : image/png');
imagepng($img);
imagedestroy($img);
?>

Step-2 Register.php

<img src="captcha.php" id="captcha"  />
<a href="#" onClick="javascript:reloadCaptcha();" />>New Code</a>

Step-3 Add Javascript for New code (In Register Page)

<script type="text/javascript">
function reloadCaptcha()
{
   document.getElementById('captcha').src = document.getElementById('captcha').src+ '?';

}
</script>



Thursday, December 29, 2011

How to add days, weeks, months to any date ?

$date = date("Y-m-d");// current date

$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 day");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 week");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +2 week");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 month");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +30 days");

Wednesday, December 28, 2011

How one can add 1 year to existing date object

<?php

//Example to add 1 year to a date object
$currentDate = date("Y-m-d");// current date

//Display the current date
echo "Current Date: ".$currentDate."<br>";

//Add one year to current date
$dateOneYearAdded = strtotime(date("Y-m-d", strtotime($currentDate)) . " +1 year");
echo "Date After adding one year: ".date('l dS \o\f F Y', $dateOneYearAdded)."<br>";

?>
Output of the program:
Current Date: 2011-12-27
Date After adding one year: Friday 28th of December 2012

Monday, December 26, 2011

In how many ways we can retrieve data in the result set of MYSQL using PHP?

imap_body &ndash; Read the message body
imap_check &ndash; Check current mailbox
imap_delete &ndash; Mark a message for deletion from current mailbox
imap_mail &ndash; Send an email message

How to reset/destroy a cookie ?


   Reset a cookie by specifying expire time in the past:

Example: setcookie(‘Test’,$i,time()-3600); // already expired time

Reset a cookie by specifying its name only

Example: setcookie(‘Test’); 

What are the features and advantages of OBJECT ORIENTED PROGRAMMING?

One of the main advantages of OO programming is its ease of modification; objects can easily be modified and added to a system there by reducing maintenance costs. OO programming is also considered to be better at modeling the real world than is procedural programming. It allows for more complicated and flexible interactions. OO systems are also easier for non-technical personnel to understand and easier for them to participate in the maintenance and enhancement of a system because it appeals to natural human cognition patterns. For some systems, an OO approach can speed development time since many objects are standard across systems and can be reused. Components that manage dates, shipping, shopping carts, etc. can be purchased and easily modified for a specific system.

Explain normalization concept?

The normalization process involves getting our data to conform to three progressive normal forms, and a higher level of normalization cannot be achieved until the previous levels have been achieved (there are actually five normal forms, but the last two are mainly academic and will not be discussed).


The First Normal Form 
(or 1NF) involves removal of redundant data from horizontal rows. We want to ensure that there is no duplication of data in a given row, and that every column stores the least amount of information possible (making the field atomic).

Second Normal Form
Where the First Normal Form deals with redundancy of data across a horizontal row, Second Normal Form (or 2NF) deals with redundancy of data in vertical columns. As stated earlier, the normal forms are progressive, so to achieve Second Normal Form, your tables must already be in First Normal Form.

Third Normal Form
I have a confession to make; I do not often use Third Normal Form. In Third Normal Form we are looking for data in our tables that is not fully dependant on the primary key, but dependant on another value in the table

What type of inheritance that php supports?

In PHP an extended class is always dependent on a single base class, that is, multiple inheritance is not supported. Classes are extended using the keyword ‘extends’.

Saturday, December 17, 2011

Text Effects using CSS3

 
.effect_10
{
color: #fff;
font: 80px Times New Roman, Times, serif;
text-shadow: 0 1px 0 #999,
0 2px 0 #999,
0 3px 0 #999,
0 4px 0 #999,
0 5px 0 #999,
0 6px 0 #000;
}
<div class="effect_10">Teachers Events</div>

Wednesday, December 7, 2011

How to play avi file in php

<OBJECT id=NSPlay
codeBase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701
type=application/x-oleobject height=310
standby="Loading Microsoft Windows Meda Player components..."
width=320 align=center
classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 name=NSPlay
bgcolor="Black">
<PARAM NAME="Filename" value="<?=$row2['video']?>">
<PARAM NAME="AnimationatStart" VALUE="true">
<PARAM NAME="TransparentatStart" VALUE="true">
<PARAM NAME="AutoStart" VALUE="true">
<PARAM NAME="ShowControls" VALUE="1">
<PARAM NAME="ShowStatusBar" VALUE="1">                                 
<embed src="<?=$row2['video']?>"
 type="application/x-mplayer2"
pluginspage="http://www.microsoft.com/windows95/downloads/contents/wurecommended/s_wufeatured/mediaplayer/default.asp" width="320" height="308" name="NSPlay"
showcontrols="1" showdisplay="0" showstatusbar="1"></embed></OBJECT>
rathoddhirendra.blogspot.com-Google pagerank and Worth