+ Reply to Thread
Results 1 to 3 of 3

Thread: Questionnaire

  1. #1
    shawakhilesh98 is offline x10Hosting Member shawakhilesh98 is an unknown quantity at this point
    Join Date
    May 2011
    Posts
    1

    Questionnaire

    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.

  2. #2
    entityx47 is offline x10Hosting Member entityx47 is an unknown quantity at this point
    Join Date
    Dec 2010
    Posts
    25

    Re: Questionnaire

    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.
    EntityX

  3. #3
    callumacrae's Avatar
    callumacrae is offline not alex mac callumacrae is just really nice
    Join Date
    Dec 2007
    Location
    Wellesbourne, England
    Posts
    5,162

    Re: Questionnaire

    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 Code:
    <!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 Code:
    <form action=""><script>document.location("http://evilsite.com/")</script>" method="post">



    Quote Originally Posted by entityx47 View 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.
    I can customise your phpBB board. Send me a PM.
    lynxphp - info, tutorials and scripts
    "A forum post should be like a skirt; long enough to cover the subject but short enough to keep things interesting."

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers