...

View Full Version : assigning a dropdown menu value to a session variable



afma_afma
05-03-2006, 03:16 PM
hi there,
can any one tell me how i can assign a drop down menu value to a session variable...thanx in advance..

ahmed

GJay
05-03-2006, 03:32 PM
<?php
session_start();
if(isset($_POST['selectname'])) {
$_SESSION['variable']=$_POST['selectname'];
}
?>
<html>
<body>
<form action="" method="post">
<select name="selectname">
<option value="a">A</option>
<option value="b">B</option>
</select>
</form>
</body>
</html>

afma_afma
05-03-2006, 06:38 PM
hello Gjay,
thanx for the suggestion.but it is not working. the drop down value is not getting assigned to the session variable.....can u tell me wht i can do...


thanx
ahmed






<?php
session_start();
if(isset($_POST['selectname'])) {
$_SESSION['variable']=$_POST['selectname'];
}
?>
<html>
<body>
<form action="" method="post">
<select name="selectname">
<option value="a">A</option>
<option value="b">B</option>
</select>
</form>
</body>
</html>

degsy
05-04-2006, 02:39 PM
Just to make sure, you are submitting your form, right?
The session variable is set from the POST var. You need to submit the form to do that.

afma_afma
05-04-2006, 05:33 PM
degsy...my form is submitting and still my drop down variable is not getting assigned...can u tell me wht i can do...abt it..

thanx
ahmed


Just to make sure, you are submitting your form, right?
The session variable is set from the POST var. You need to submit the form to do that.

degsy
05-05-2006, 03:15 PM
Post your example code



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum