示例#1
0
<?php

ini_set('display_errors', 'On');
?>
<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  <title>Manage Events</title>
</head>
<body>
<?php 
//Handle Submissions -- no error handling on POST
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    //run the geocoder
    include 'geocoder.php';
    $latlong = bingGeocode($_POST['street'], $_POST['city'], $_POST['state'], $_POST['zip']);
    //report results
    echo "<section>\r\n";
    echo "<h1>Results</h1>\r\n";
    echo "<p>" . $_POST['street'] . "<br>";
    echo $_POST['city'] . ", " . $_POST['state'] . " " . $_POST['zip'] . "</p>";
    if (isset($latlong['error']) == true) {
        echo "<p>Geodata could not be found!  Check the address.</p>";
    } else {
        $lat = $latlong['lat'];
        $long = $latlong['long'];
        echo "<ul><li>Latitude: " . $lat . "</li>\r\n";
        echo "<li>Longitude: " . $long . "</li>\r\n";
        echo "</ul>\r\n";
        echo "<p>Link: <a href='http://maps.google.com/?q=" . $lat . "," . $long . "'>Google Map</a>\r\n";
    }
示例#2
0
 } else {
     $website = null;
 }
 /* Convert state_id to the string it references */
 $mysqli = connectReuseDB();
 if (!($stmt = $mysqli->prepare("SELECT abbreviation FROM  `States` WHERE id = ?"))) {
     echo "Prepare failed : (" . $mysqli->connect_errno . ")" . $mysqli->connect_error;
 }
 $stmt->bind_param('i', $stateId);
 $stmt->bind_result($state);
 $stmt->execute();
 $stmt->fetch();
 $stmt->close();
 $mysqli->close();
 /* Geocode address for storage */
 $latlong = bingGeocode($address, $city, $state, $zipcode);
 if ($latlong == false) {
     $latitude = null;
     $longitude = null;
 } else {
     $latitude = $latlong['lat'];
     $longitude = $latlong['long'];
 }
 $mysqli = connectReuseDB();
 /* prepare the statement*/
 if (!($stmt = $mysqli->prepare("INSERT INTO Reuse_Locations (name, address_line_1, address_line_2, city, state_id, zip_code, phone, website, latitude, longitude) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"))) {
     echo "Prepare failed : (" . $mysqli->connect_errno . ")" . $mysqli->connect_error;
 }
 /* bind the variables */
 if (!$stmt->bind_param('ssssiissdd', $name, $address, $address2, $city, $stateId, $zipcode, $phone, $website, $latitude, $longitude)) {
     echo "Binding failed. (" . $mysqli->connect_errno . ")" . $mysqli->connect_error;