Tuesday, January 19, 2010

How to store multiple values in a session variable with in a form submit in php

Note : Save this page session.php
Note : Remove "\" from all HTML tag and php start tag

<\?php
session_start();

$sessValue = "";
    if(isset($_REQUEST['submit']))
    {
        $sessValue = $_REQUEST['sessValue'];
        if(!isset($_SESSION['sessValue1']))
        {
            echo $_SESSION['sessValue1']=$sessValue;
        }
        else
        {
            echo $_SESSION['sessValue1']=$_SESSION['sessValue1'].$sessValue;
        }
    }
?>
<\html>
<\body>
<\form name="frm" action="session.php" method="post">
    <\input type="text" name="sessValue">
    <\input type="submit" name="submit" value="submit">
<\/form>
<\/body>
<\/html>

No comments: