Beispiel #1
0
	<br><br><br>
    <div id="info">
	<h2>Survey Data</h2>
	<hr>
		
	<form action="view.php" method="post">	
	 <select name="sort">
	  <option value="day">Today</option>
	  <option value="month">This Month</option>
	  <option value="year">This Year</option>
	 </select> 
	 
	  <select name="sites">
	 
	 <?php 
$db1 = new db1();
$accessSites = $db1->getAccessSites();
$self = htmlspecialchars($_SERVER["PHP_SELF"]);
//The information of the form will be sent back to self. This is done to change the content of the page when the submit button is clicked.
$numberOfSites = count($accessSites['SiteID']);
//Number of sites found in the database is equal to number of site IDs.
echo "<form method='post' action='{$self}'>";
//This is the HTML form header.
for ($i = 1; $i <= $numberOfSites; $i++) {
    $SiteName = $accessSites['SiteName'][$i - 1];
    $SiteID = $accessSites['SiteID'][$i - 1];
    echo "<option value='{$SiteID}'>{$SiteName}</option>";
}
?>
		<input type="submit" value="Sort">
	
<?php

session_start();
require_once "boaterSurveyDB.php";
$sql = new mysqli("localhost", "root", "", "nhvbsr");
if ($sql->connect_errno) {
    printf("Connect failed: %s\n", $sql->connect_error);
    exit;
}
if ($_POST) {
    $db1 = new db1();
    $hostID = $_SESSION['UserID'];
    $siteID = $db1->getSiteID($hostID);
    $time = $_POST['time'];
    $date = $_POST['date'];
    $status = $_POST['status'];
    $sor = $_POST['registrationState'];
    $type = $_POST['boat'];
    $interaction = $_POST['interaction'];
    $lastSite = $_POST['lastSiteVisited'];
    $lastTown = $_POST['lastTownVisited'];
    $lastState = $_POST['lastStateVisited'];
    $drained = $_POST['drained'];
    $rinsed = $_POST['rinsed'];
    $dried = $_POST['dryForFiveDays'];
    $aware = $_POST['awareness'];
    $found = $_POST['specimenFound'];
    $bow = $_POST['Bow'];
    $prep = $sql->prepare("INSERT INTO surveys(LakeHostID, InputDate, InspectionTime,SiteID, LaunchStatus, RegistrationState, BoatType, previousInteraction, LastSiteVisited, LastTownVisited, LastStateVisited, Drained, Rinsed, DryForFiveDays, BoaterAwareness, SpecimenFound,  BowNumber)\r\n\t\tVALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
    $prep->bind_param('ississsisssiiisii', $hostID, $date, $time, $siteID, $status, $sor, $type, $interaction, $lastSite, $lastTown, $lastState, $drained, $rinsed, $dried, $aware, $found, $bow);
    $prep->execute();
    public function viewAccessSites()
    {
        $db1 = new db1();
        $accessSites = $db1->getAccessSites();
        $self = htmlspecialchars($_SERVER["PHP_SELF"]);
        //The information of the form will be sent back to self. This is done to change the content of the page when the submit button is clicked.
        $numberOfSites = count($accessSites['SiteID']);
        //Number of sites found in the database is equal to number of site IDs.
        echo "<form method='post' action='{$self}'>";
        //This is the HTML form header.
        for ($i = 1; $i <= $numberOfSites; $i++) {
            echo $i;
            $SiteName = $accessSites['SiteName'][$i - 1];
            $SiteID = $accessSites['SiteID'][$i - 1];
            echo <<<_END
<input type='radio' name='SiteID' value={$SiteID}>
{$SiteName} <br/>
_END;
        }
        //The for loop is used to loop through the list of surveys. Each survey will be presented as a radio button. Surveys are labeled by time, status, state, and boat type.
        echo "<input type='submit' name='submitButton' value='Edit/Flag' ></input>";
        echo "</form>";
    }