Friday, May 24, 2013

Prevent form resubmitting using php


Simple method for preventing form resubmission using php.

<?php
if(!isset($_SESSION))
{
session_start();
}
if($_POST)
{
if($_SESSION['token'] == $_POST['token'])
{
echo $_POST['txt'];
echo '</br>Submitting';
// Place form action code here
}
else
{
echo 'Re Submitting';
}
}
$_SESSION['token'] = $token = rand();
?>

<form name="frm" action="" method="post" >
<input type="text" name="txt" />
<input type="hidden" name="token" value="<?php echo $token; ?>" />
<input type="submit" />
</form>

Monday, May 13, 2013

Add QR Code for wordpress post

To add QR code for wordpress post, use the following code


    < img src="http://api.qrserver.com/v1/create-qr-code/?size=200x200&data="<?php the_permalink() ?>" alt="QR Code for <?php the_title(); ?>" />