Note that there are some explanatory texts on larger screens.

plurals
  1. POsession variable not being stored from dropdown menu in php
    primarykey
    data
    text
    <p>I have looked up many different ways of storing session variables and cant seem to find why my session variable is not being stored from my dropdown menu. here is my code for campaign_select.php which then goes to store_select.php upon the push of the submit button.</p> <pre><code> &lt;?php session_start (); $host="localhost"; // Host name $username="sxx2"; // Mysql username $password="xxxxx!"; // Mysql password $db_name="sxxxxx"; // Database name $tbl_name="campaign"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $query = "SELECT campaignname FROM campaign"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { $dd .= "&lt;option value='{$row['campaignID']}'&gt;{$row['campaignname']}&lt;/option&gt;"; } if ($_POST['Submit']) { if(isset($_POST['campaignname'])) { $_SESSION['campaign']=$_POST['campaignName']; } } $_SESSION['test']="bye"; ?&gt; &lt;form action="store_select.php" method="post"&gt; &lt;select name="campaignName" id="campaignname"&gt;&lt;? echo $dd; ?&gt;&lt;/select&gt; &lt;input name="Submit" type="submit" value="Submit"&gt; &lt;/form&gt; </code></pre> <p>and here is store_select.php:</p> <pre><code>&lt;?php session_start(); $host="localhost"; // Host name $username="sxxxx2"; // Mysql username $password="Wxxxx1!"; // Mysql password $db_name="xxxx2"; // Database name $tbl_name="users"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $campaign=$_SESSION['campaign']; echo $_SESSION['campaign']; echo $_SESSION['test']; $query = "SELECT storename FROM stores WHERE campaignname='$campaign'"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { $dd .= "&lt;option value='{$row['storeID']}'&gt;{$row['storename']}&lt;/option&gt;"; } ?&gt; &lt;form action="" method="post"&gt; &lt;select name="stores"&gt;&lt;? echo $dd; ?&gt;&lt;/select&gt; &lt;/form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload