mysql - How to grab selected value from changing drop down box php and html -


<?php session_start(); include_once "dbconnect.php"; if(isset($_post['btn_up'])){   $email = $_post['sn'];   if($email == ''){     echo 'there error';   }else{     echo $email;     echo "something happened";   } } var_dump($email); ?> <!doctype html> <html> <head> <title> admin </title> </head> <body>    <form method='post'>     <label for="select">school name</label>     <select name="sn">         <option value="-" selected data-default>-</option>         <?php             $query = mysql_query("select * users school = 'sn'");             while($rowtwo = mysql_fetch_array($query)){                 ?>                 <option value="<?php echo $rowtwo['email']; ?>"><?php echo $rowtwo['email']; ?></option>                 <?php             }         ?>     </select>  <button type="submit" name='btn_up'>up</button> </form>  </body> </html> 

i'm working on making admin page, section of code. on viewers side looks right, when select value drop down , press "btn_up", code doesn't save user email in variable $email, thats why checks if blank because telling me nothing being saved value. how can have save whatever value selected drop down list? var_dump() gave me error

there errorstring(0) ""

 <script src="jquery-3.1.0.js"></script>     <script>         $(function () {             $('#selectnumber').change(function(){                 alert('.val() = ' + $('#selectnumber').val() + '  ,  html() = ' + $('#selectnumber option:selected').html() + '  , .text() = ' + $('#selectnumber option:selected').text());             })         });     </script>  <select id="selectnumber">             <option value="1">one</option>             <option value="2">two</option>             <option value="3">three</option>             <option value="4">four</option>         </select> 

click see out put screen

thanks... :)


Comments