WAMFT1 Posted September 28, 2016 Share Posted September 28, 2016 (edited) Hi All I am trying to use a dropdown box to get 'id' from a form and use this to update a record but I can't get it to work. I know I am using old code but don't have time to update yet. Any help would be appreciated. FORM: <form action="terminate_user.php" method="post" name="aid" id="aid"> <table width="600" border="0" class="Text_Standard"> <tr> <td><span class="standard_left">User: </span></td> <td><span class="standard_left"> <select name="aid" class="standard_left" id="aid"> <option value="" selected="selected"> </option> <?php $result = mysql_query("SELECT id, LastName, FirstName FROM `eusers` WHERE Status='CURRENT' ORDER by LastName ASC"); while ($row = mysql_fetch_array($result)){ echo '<option value="'. $row['id'] .'">'. $row['LastName'] .', '. $row['FirstName'] .'</option>'; }?> </select> <input type="Submit" name="Submit" id="Submit" value="Confirm and Terminate User" /> </form> QUERY: <?php if(isset($_POST['Submit'])) { $aid = ($_GET['aid']); //from form above $mysql_query = "UPDATE eusers SET Status='TERM' WHERE id='$aid'"; echo "Saved!"; }?> Edited September 28, 2016 by WAMFT1 Quote Link to comment https://forums.phpfreaks.com/topic/302250-using-dropdown-as-it-to-update-record/ Share on other sites More sharing options...
Solution Barand Posted September 28, 2016 Solution Share Posted September 28, 2016 Try $_POST['aid'] instead of $_GET. Quote Link to comment https://forums.phpfreaks.com/topic/302250-using-dropdown-as-it-to-update-record/#findComment-1537868 Share on other sites More sharing options...
WAMFT1 Posted September 29, 2016 Author Share Posted September 29, 2016 Thanks, between this and not having the code in the right place I have managed to get this working again. Quote Link to comment https://forums.phpfreaks.com/topic/302250-using-dropdown-as-it-to-update-record/#findComment-1537886 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.