Saturday 9 January 2016

Cookies



<?php
if(isset($_POST['s1']))
{
    $u=$_POST['t1'];
        if(isset($_POST['c1']))
        {
            setcookie('mydt',$u,time()+60*60*24*7);
            echo "Cookies stored.........";
            echo $u;
        }
}
?>

<?php
    if(isset($cookie['mydt']))
    {
    echo $u."Cookie Retrived";
    echo ($_COOKIE['mydt']);
    echo "cookies Retrived...";
    }

?>
<form id="form1" name="form1" method="post" action="">
  <table width="300" border="1" align="center">
    <tr>
      <td width="88">User</td>
      <td width="196"><input name="t1" type="text" id="t1" /></td>
    </tr>
    <tr>
      <td>Password</td>
      <td><input name="t2" type="text" id="t2" /></td>
    </tr>
    <tr>
      <td colspan="2"><div align="center">
          <input name="c1" type="checkbox" id="c1" value="checkbox" />
      Remember Me </div></td>
    </tr>
    <tr>
      <td colspan="2"><div align="center">
        <input name="s1" type="submit" id="s1" value="Submit" />
      </div>  <div align="center"></div></td>
    </tr>
  </table>
</form>

No comments:

Post a Comment