justlukeyou Posted May 26, 2012 Share Posted May 26, 2012 Hi, I have code which contains and submits only 'question' to the 'question' column from a form. However, I am struggling to add a second input called 'comments' into the 'comments' column. Does anyone know how to do this please? <?php if(isset($_POST['form_id'])){ $question = mysql_real_escape_string(trim($_POST['question'])); $comments = mysql_real_escape_string(trim($_POST['comments'])); $error = false; if(!isset($question) || empty($question)) { $error = "Please enter a question."; } if(preg_match("/[a-zA-Z0-9]{1,}$/", $question) == 0 && !$error) { $error = "The question you entered must contain only letters or numbers."; } if(preg_match("/[a-zA-Z0-9]{1,}$/", $comments) == 0 && !$error) { $error = "The comments you entered must contain only letters or numbers."; } if(!$error) { $query = mysql_query("INSERT INTO discussion (question, comments) VALUES ('".$question."', '".$comments."')"); if($query) { } else { $error = "There was a problem with the registration. Please try again."; } } } ?> Link to comment https://forums.phpfreaks.com/topic/263187-submit-multiple-inputs-can-only-do-1/ Share on other sites More sharing options...
.josh Posted May 26, 2012 Share Posted May 26, 2012 1) did you echo $comments to see if it contains expected value? 2) do you have a comments column in your db table? 3) Is the question being inserted okay, just not the comment? Link to comment https://forums.phpfreaks.com/topic/263187-submit-multiple-inputs-can-only-do-1/#findComment-1348845 Share on other sites More sharing options...
justlukeyou Posted May 26, 2012 Author Share Posted May 26, 2012 1. successfully echoes a test comment manually entered into db 2. yep 3. with this code nothing is being inserted into the db. When I base the code on just questions only this enters. When I try to write code for both questions and comments nothing enters. Link to comment https://forums.phpfreaks.com/topic/263187-submit-multiple-inputs-can-only-do-1/#findComment-1348847 Share on other sites More sharing options...
justlukeyou Posted May 26, 2012 Author Share Posted May 26, 2012 Sorted now, I was being a silly sausage. I didn't set the form box to post to the db. Link to comment https://forums.phpfreaks.com/topic/263187-submit-multiple-inputs-can-only-do-1/#findComment-1348848 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.