Grigori Perelman said:
Easy.
Code:
<?php
//Example of store into database.
include "databaseconnection.php";
/*Run these SQL querys -
Create table surveys(id int not null auto_increment primary key, name varchar(30), answer1 varchar(100), answer2 varchar(100), answer3 varchar(100), comments varchar(200));
*/
$name = mysql_real_escape($_POST['name']); # name the user supplys from html form "name".
$answer1 = mysql_real_escape($_POST['answer1']); # answer 1 the user supplys from html form "answer1"
$answer2 = mysql_real_escape($_POST['answer2']); # Answer 2 the user supplys from html form "answer2".
$comments = mysql_real_escape($_POST['comments']); # user comments from html form "comments".
$query = "INSERT INTO `survey` (id, name, answer1, answer2, comments) VALUES (NULL, $name, $answer1, $answer2, $comments);";
mysql_query($query);
?>
You have a SQL injection in your code
First of all you should be using mysql_real_escape_string() if you choose to use the "mysql" extension over "mysqli" (MySQL Improved).
Secondary, you do not use ' around your interpolated variables, meaning that you can inject code into the fields. Say 'answer2' had the value of (without quotation marks) "1, 2) UNION ... --".
What you should do to fix this is to change the code to use marks so that the escape string have an effect:
PHP:
$query = sprintf('INSERT INTO `table` (`name`, `answer1`, `answer2`, `comment`) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', $name, $answer1, $answer2, $comment);
(I choose to use sprintf because it makes the code much more readable than having a huge string filled with interpolated variables)