PHP - Hold Session variable from Select Option box to every page -
i seem having problem , after hours of searching , messing different ideas can't seem come seems simple php session problem select options menu.
all want simple have selected hotel name dropdown hold till changed, , goes every page. thought, of yea lets use sessions. doesn't seem work keeps refreshing data. here code, , maybe 1 of guys can come solution. appreciate it!
we using json file populate menu using curl call data , decode json.
here dropdown code:
<select id="hotelselected" name="hotelselected"> <?php sort($hotelname); foreach($hotelname $value): echo '<option value="'.$value.'"'.ucfirst($value).'</option>'; endforeach; ?> </select>
and tried create session doing this:
$_session['hotelname'] = $hotelname;
and need session carry on every page. , possibly echo on pages possibly using this:
echo $_session['hotelname'];
any appreciated or redirect me forum can fix problem. thank guys!
you should use session_start();
@ top of every php file uses sessions. if have form contains select
tag , after submitting form should use $_post['hotelselected']
grabbing tha value of option selected user.
edit 1:
<select id="hotelselected" name="hotelselected"> <?php sort($hotelname); foreach($hotelname $key=>$value): echo '<option value=($_session['hotelname'][$key]):"'.$_session['hotelname'][$key].'"'.ucfirst($_session['hotelname'][$key]).'?"'.$value.'"'.ucfirst($value).'</option>'; endforeach; ?> </select> <?php $_session['hotelname']=$hotelname;
Comments
Post a Comment