IChaps Posted November 1, 2016 Share Posted November 1, 2016 Hello. I'd like to request a little guidance with regards forms and updating a database table please. I've created a form which has a dropdown list. I'd just like to enquire:- 1. How do I pass the selected result from the dropdown list to a variable? (at present I've written:- $user_gender = $_POST["profile_gender"] 2. I'm unable to update the database table. The database opens and there's no errors reported. I'd just like to ask the following looks ok? $sql = "UPDATE registration_table SET Gender='$user_gender' WHERE Member_id='$userID'"; Thank You. Link to comment Share on other sites More sharing options...
Ingolme Posted November 2, 2016 Share Posted November 2, 2016 Assuming the form was submitted properly, the value from the dropdown will be in one of the elements in $_POST or $_GET. You could assign it to a variable or use it directly. You should use prepared statements for your queries. Here's the tutorial page for prepared statements: http://www.w3schools.com/php/php_mysql_prepared_statements.asp Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now