Questionnaire

shawakhilesh98

New Member
Messages
1
Reaction score
0
Points
0
I want to upload a questionnaire on my website so as to enable people to fill it up and submit it.How can i make a questionnaire containing text area and radio button and how will I get the data from the form submitted by the users.
 

entityx47

New Member
Messages
25
Reaction score
0
Points
0
Microsoft Office Access or previously known as Microsoft Access is a database management system. Access stores data in it's own format. It can also import or link directly to data stored in other applications and databases.

It is a great resource for web developers to embed forms such as questioners, surveys, polls, etc..

Maybe it's something worth looking into depending on how computer literate you may be? It actually isn't to difficult to get familiar with. If you need any help just reply here or shoot me a private message.
 

callumacrae

not alex mac
Community Support
Messages
5,257
Reaction score
97
Points
48
For this, you'll want a simple PHP form and a connection to a database - probably MySQL because that's what x10hosting offers. You can use something like the following (minified) code:

PHP:
<!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>

Read my article on PDO here. Please use the above code to learn from, don't copy it directly ;)

When getting forms to submit to the same page, do not use $_SERVER['PHP_SELF'], as it leaves the page open to XSS injection; input.php/%22%3E%3Cscript%3Edocument.location(%22http%3A%2F%2Fevilsite.com%2F%22)%3C%2Fscript%3E is a perfectly valid URL and will result in the following HTML:

HTML:
<form action=""><script>document.location("http://evilsite.com/")</script>" method="post">




Microsoft Office Access or previously known as Microsoft Access is a database management system. Access stores data in it's own format. It can also import or link directly to data stored in other applications and databases.

It is a great resource for web developers to embed forms such as questioners, surveys, polls, etc..

Maybe it's something worth looking into depending on how computer literate you may be? It actually isn't to difficult to get familiar with. If you need any help just reply here or shoot me a private message.

It really isn't. For a start, x10hosting doesn't support it, but it's terrible for web applications.
 
Top