Pallab Kumar Laskar
Pallab Kumar Laskar

Reputation: 159

how to store selected value of a drop down list in to a session variable in php

currently i am working on a system. here i have a drop down list and its values are populating from database. now what i need is when ever some one selects a record from the list the selected value should be get stored in a session variable which ll get displayed in an another page. can we do so. i am coding in php. my code is:

<td align="center">
                <?php
                $sql_dep=" Select * from   places_tbl";
                $row_dep = $db->Execute($sql_dep);
                $total_dep  = $row_dep->RecordCount();
                ?>
                <select name="place" class="txtbx08" id="place">
                <option value="">--Please Select City--</option>
                <?php if($total_dep>0) {
                while(!$row_dep->EOF)
                {   
                ?>
                  <option value="<?php echo $row_dep->fields["place_id"];?>">
                  <?php echo ucfirst($row_dep->fields["place_name"]); ?>
                  </option>
                  <?php 
                    $row_dep->MoveNext();
                    }}
                  ?>
                </select></td>

Upvotes: 0

Views: 1995

Answers (1)

silkfire
silkfire

Reputation: 25945

I'm not sure how you're retrieving the selected value (assumingly through POST), but the normal procedure would be:

session_start();

$_SESSION['place'] = $_POST['place'];

Upvotes: 1

Related Questions