<!DOCTYPE html>
<html>
<head>
<title>Questionnaire</title>
</head>
<body><?php
if ($_SERVER['REQUEST_METHOD'] === 'POST')
{
// Database connection info
$host = 'localhost';
$port = 3306;
$database = 'yourdatabase';
$username = 'yourusername';
$password = 'yourpassword';
// Construct the DSN
$dsn = "mysql:host=$host;port=$port;dbname=$database";
// Create the connection
$db = new PDO($dsn, $username, $password);
$statement = $db->prepare("INSERT INTO questionnaire (name, text, bla) VALUES (?, ?, ?)");
$statement->execute(array($_POST['name'], $_POST['text'], $_POST['bla']));
echo '<p>Thanks for completing the questionnaire!</p></body></html>';
exit;
}
?>
<form action="#" method="post">
<p><strong>Your name:</strong> <input type="text" name="name" /></p>
<p><strong>Text:</strong> <input type="text" name="text" /></p>
<p><strong>bla:</strong> <input type="text" name="bla" /></p>
<input type="submit" value="Submit!" />
</form>
</body>
</html>