stonechest
Gebruiker
- Lid geworden
- 25 sep 2006
- Berichten
- 31
Ik heb twee php pagina's die samengevoegt moeten worden .
De bovenste pagina verstuurd een formulier naar mijn sql database.
Nadat de gegevens ingevuld zijn wil ik graag dat de onderste php pagina wordt uitgevoerd.
Hoe kan ik deze twee combineren tot 1 werkend bestand.
De bovenste pagina verstuurd een formulier naar mijn sql database.
Nadat de gegevens ingevuld zijn wil ik graag dat de onderste php pagina wordt uitgevoerd.
Hoe kan ik deze twee combineren tot 1 werkend bestand.
PHP:
<?php
} else {
if ((isset($first_album)) && ($first_album==1)) {
echo '<input type="hidden" name="gallery_id" value="'.$_REQUEST['gallery_id'].'">';
}
if ($this_thumbtype==2) {
echo '<input type="submit" value="'.$LANG_IMG_FIELD[21] .'»" class="formbutton" onClick="this.disabled=true; this.value=\''.$LANG_IMG_FIELD[13].'...\'; this.form.submit();">';
} else {
echo '<input type="submit" value="Save New" class="formbutton" onClick="this.disabled=true; this.value=\''.$LANG_IMG_FIELD[13].'...\'; this.form.submit();">';
}
?>
<input type="hidden" name="action" value="new">
<?php
}
?>
PHP:
<?php
require("phpsqlajax_dbinfo.php");
define("MAPS_HOST", "maps.google.com");
define("KEY", "abcdefg");
function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','<',$htmlStr);
$xmlStr=str_replace('>','>',$xmlStr);
$xmlStr=str_replace('"','"',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&',$xmlStr);
return $xmlStr;
}
// Opens a connection to a mySQL server
$connection=mysql_connect ($localhost, $username, $password);
if (!$connection) {
die('Not connected : ' . mysql_error());
}
// Set the active mySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}
// Select all the rows in the markers table
$query = "SELECT * FROM snipe_gallery_data WHERE 1";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
// Initialize delay in geocode speed
$delay = 0;
$base_url = "http://" . MAPS_HOST . "/maps/geo?output=xml" . "&key=" . KEY;
// Iterate through the rows, geocoding each location
while ($row = @mysql_fetch_assoc($result)) {
$geocode_pending = true;
while ($geocode_pending) {
$location = $row["location"];
$id = $row["id"];
$request_url = $base_url . "&q=" . urlencode($location);
$xml = simplexml_load_file($request_url) or die("url not loading");
$status = $xml->Response->Status->code;
if (strcmp($status, "200") == 0) {
// Successful geocode
$geocode_pending = false;
$coordinates = $xml->Response->Placemark->Point->coordinates;
$coordinatesSplit = split(",", $coordinates);
// Format: Longitude, Latitude, Altitude
$latitude = $coordinatesSplit[1];
$longitude = $coordinatesSplit[0];
$query = sprintf("UPDATE snipe_gallery_data " .
" SET latitude = '%s', longitude = '%s' " .
" WHERE id = '%s' LIMIT 1;",
mysql_real_escape_string($latitude),
mysql_real_escape_string($longitude),
mysql_real_escape_string($id));
$update_result = mysql_query($query);
if (!$update_result) {
die("Invalid query: " . mysql_error());
}
} else if (strcmp($status, "620") == 0) {
// sent geocodes too fast
$delay += 100000;
} else {
// failure to geocode
$geocode_pending = false;
echo "location " . $location . " failed to geocoded. ";
echo "Received status " . $status . "\n";
}
usleep($delay);
}
}
?>