Open source survey management

example.php 1.8KB

    <?php require_once("survey_func.php"); $survey = new OpenForm; $survey->conn = mysqli_connect("127.0.0.1", "survey_user", "yourpass", "surveys"); $survey->table = "results"; $survey->id = "first"; $survey->add_module("Name", "What is your name?", "name", ModuleType::TEXTBOX, null, null, null); $radio = array( "Linux" => "lin", "Windows" => "win", "Mac OS" => "mac" ); $survey->add_module("Operating System", "What OS do you use?", "choice_os", ModuleType::RADIO, $radio, null, null); $chkbox = array( "CS" => "cs", "Art" => "art", "Business" => "business" ); $survey->add_module("Major", "What are you majoring in?", "major", ModuleType::CHECKBOX, $chkbox, null, null); $survey->add_module("Age", "How old are you?", "age", ModuleType::NUM_INPUT, null, null, "years"); $rankings = array( 5 => "Strongly agree", 4 => "Agree", 3 => "Neutral", 2 => "Disagree", 1 => "Strongly Disagree" ); $ranking_questions = array( "foss" => "I believe in FOSS ideology", "rms" => "Richard Stallman is the one true god" ); $survey->add_module("Ranking", "Please rank the following from strongly agree to strongly disagree", null, ModuleType::RANKING, $ranking_questions, $rankings, null); $countries = array( "CA" => "Canada", "US" => "United States", "DE" => "Germany", "OT" => "Other" ); $survey->add_module("Country", "What country do you live in?", "country", ModuleType::DROPDOWN , $countries, null, null); $survey->add_module("Meta", "How do you feel about this question?", "metaquestion", ModuleType::TEXTAREA, null, null, null); $res = $survey->create("Stephen's Survey", "This is my survey"); if ($res == 2) { echo "<b>There was an error submitting your query to the database.</b>"; } elseif ($res == 1) { echo "<b>Success! Your response has been received.</b>"; } ?>