Mamo Posted April 15, 2013 Share Posted April 15, 2013 Hi is there a simple code for asking and answering a question, cause i don't know much about PHP or MySQL . can any one please help me . thanks Quote Link to comment Share on other sites More sharing options...
lemmin Posted April 15, 2013 Share Posted April 15, 2013 What kind of question? Multiple choice? Feedback text? Quote Link to comment Share on other sites More sharing options...
Mamo Posted April 15, 2013 Author Share Posted April 15, 2013 question like what i am asking here?...........Technical and coding question. Quote Link to comment Share on other sites More sharing options...
lemmin Posted April 15, 2013 Share Posted April 15, 2013 Ok. Where will the answer go? Into a database? Emailed to someone? Quote Link to comment Share on other sites More sharing options...
Mamo Posted April 15, 2013 Author Share Posted April 15, 2013 to database. I am using a local server (WAMP) , and phpMyAdmin. Quote Link to comment Share on other sites More sharing options...
godleydesign Posted April 15, 2013 Share Posted April 15, 2013 Not really sure we understand what you mean? What do you mean asking a question and getting an answer? Are you referring to a security to validate if a customer is a real person? Quote Link to comment Share on other sites More sharing options...
Mamo Posted April 15, 2013 Author Share Posted April 15, 2013 what i meant is to ask question, and then any other user can answer (replay) my question. Quote Link to comment Share on other sites More sharing options...
lemmin Posted April 15, 2013 Share Posted April 15, 2013 It sounds like you just want a generic feedback-type form. Here is some simply code that would push the input of a textarea into your database: <form method="post"> Question:<br/> <textarea name="answer"></textarea> <input type="submit"/> </form> <?php if (isset($_POST['answer'])) //Form was submitted { mysql_connect('localhost', 'user', 'pass'); mysql_select_db('database'); mysql_query('INSERT INTO tablename VALUES ("'.$_POST['answer'].'")'); } ?> That is very generic and obviously needs to be adjusted for your scenario. Is this the sort of form you are looking for? Quote Link to comment Share on other sites More sharing options...
Mamo Posted April 15, 2013 Author Share Posted April 15, 2013 It sounds like you just want a generic feedback-type form. Here is some simply code that would push the input of a textarea into your database: <form method="post"> Question:<br/> <textarea name="answer"></textarea> <input type="submit"/> </form> <?php if (isset($_POST['answer'])) //Form was submitted { mysql_connect('localhost', 'user', 'pass'); mysql_select_db('database'); mysql_query('INSERT INTO tablename VALUES ("'.$_POST['answer'].'")'); } ?> That is very generic and obviously needs to be adjusted for your scenario. Is this the sort of form you are looking for? Thank you, i understood that, but i need other users on the website to be able to answer the question that i saved . Like the concept of "phpfreaks" website. Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 15, 2013 Share Posted April 15, 2013 No, it's not simple. You could use one of the many free or paid forum software out there. Quote Link to comment Share on other sites More sharing options...
lemmin Posted April 15, 2013 Share Posted April 15, 2013 I agree with Jessica; the easiest (and incidentally best) solution would be to use a forum solution like Wordpress or Drupal. Quote Link to comment Share on other sites More sharing options...
Mamo Posted April 16, 2013 Author Share Posted April 16, 2013 I agree with Jessica; the easiest (and incidentally best) solution would be to use a forum solution like Wordpress or Drupal. Thank you Quote Link to comment Share on other sites More sharing options...
Mamo Posted April 16, 2013 Author Share Posted April 16, 2013 No, it's not simple. You could use one of the many free or paid forum software out there. Thank you Quote Link to comment 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.