ridgey28 Posted April 29, 2010 Share Posted April 29, 2010 I have been trying to figure out how to enter the the contents of a form select into a MYSQL database. I am trying to setup a security question and answer for my project where you choose from several security questions. I have tried several different things but to no avail I cannot figure this out. <p><label for="question" title="question" accesskey="s">Security Question:</label> <select id="question" name="question"> <option value="What is your Mother's maiden name?">What is your Mother's maiden name?</option> <option value="What is the name of your first school?">What is the name of your first school?</option> <option value="What is the name of your first pet?">What is the name of your first pet?</option> <option value="What is your favourite food?">What is your favourite food?</option> </select></p> $question =$_POST['question']; $query5 = "INSERT INTO admin VALUES ('1','$name','$surname','$uname','$active_code','$md5_id','$authorise','$answer','$question','$pword')"; mysql_query($query5); Everything else goes into the database fine so it has narrowed it down to this wee problem. Any help would be appreciated. Thanks in advance Link to comment https://forums.phpfreaks.com/topic/200225-enter-a-form-select-option-into-a-mysql-database/ Share on other sites More sharing options...
mrMarcus Posted April 29, 2010 Share Posted April 29, 2010 first things first, switch out (or simeply add, i guess), mysql_error() .. so your query function will look like this now: mysql_query($query5) or trigger_error(mysql_error()); post errors, if any. Link to comment https://forums.phpfreaks.com/topic/200225-enter-a-form-select-option-into-a-mysql-database/#findComment-1050756 Share on other sites More sharing options...
ridgey28 Posted April 30, 2010 Author Share Posted April 30, 2010 It is working now. Strange as I didn't change anything from the above code. Maybe it was a server speed issue!! Now for my 2nd question is above a secure way to place it in the database? Link to comment https://forums.phpfreaks.com/topic/200225-enter-a-form-select-option-into-a-mysql-database/#findComment-1050949 Share on other sites More sharing options...
Ken2k7 Posted April 30, 2010 Share Posted April 30, 2010 I can't really tell with just those lines of code, but take a look at mysql_real_escape_string to secure inputs if you aren't already using it. Link to comment https://forums.phpfreaks.com/topic/200225-enter-a-form-select-option-into-a-mysql-database/#findComment-1051100 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.