Share on Google+Share on Google+

Create session variable.

In this example you will learn how to create session variable in PHP.

Create session variable

In this example, you will learn how to create session variable in HTML form. You can use your email id to find the session value.

First you will have to create a form in HTML in which you will have to create an Email field and fix submit buttton.

Create a session variable code in PHP and call the value of this variable in the HTML form using post action command of PHP.

Email has been set to find the session value, if the program finds the correct email address, the value of the session is set. 

session_start (); #session start
session_register ("email"); #session Register
$_SESSION["email"]=$email; #session Veriable
$sessionvalue= $_SESSION["email"]; #Find Session variable value
echo "Your Email ID is ".$sessionvalue;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<head><title>Session Register</title></head>
<form name="session" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
<table width="80%" border="0" cellspacing="0" cellpadding="0" style="color:#333333;"> 

<td width="20%" height="27" style="padding-left:10px;">Email</td> 
<td width="32%">: <input type="text" name="email" class="inputbox" /></td> 
<td width="48%" align="left"></td>
<tr><td><input name="submit" type="submit" value="Submit" onClick="return validate(this);"/></td></tr> 



Posted on: July 30, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null