Monday, March 24, 2014

Simple example of SESSION in PHP

SessionMethod1.php


<html>
<form method="POST">
<table align="center">
<tr>
<td>
UserName:
</td>
<td>
<input type="text" name="username"?>
</td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="password"/>
</tr>
<tr>
<td><input type="submit" value="Submit" name="submit"/></td>
</tr>
</table>
</form>
</html>
<?php
session_start();
$_SESSION["un"]=$_POST['username'];
$_SESSION["pw"]=$_POST['password'];
?>

SessionMethod2.php


<?php
session_start();

echo $_SESSION["un"]."<br/>";
echo $_SESSION["pw"];
?>

Output:-





No comments:

Post a Comment