alles werkt nu, ik ben door jullie commentaar op het juiste spoor gezet. Bedankt hiervoor.
Zijn er nog overige aanpassingen die bijv uit beveiligings oogpunt beter kunnen? ect.....
*update
heb het inmiddels weer werkend met e-mail en captcha code.
nu lukt het me alleen niet om de "succes verzonden" melding rechts onderin te zetten.
mooier is denk ik op een andere pagina waarna je door kunt gaan naar de main page.
----------------------------------------------------------
Ik had dit formulier nog staan tussen m'n test files. echter krijg ik het niet meer aan de praat.
Ik mis het e-mail adres waar het naartoe gezonden wordt
en de captcha code werkt niet.
Wie kan mij helpen?
de test url:
http://www.modelbouwlocaties.nl/contact-form/contact-form-3.php
<?php
$contact_form_field_subject = 'Onderwerp:';
$contact_form_field_location = 'Locatie:';
$contact_form_field_name = 'Naam locatie:';
$contact_form_field_adres = 'Adres:';
$contact_form_field_postcode = 'Postcode:';
$contact_form_field_city = 'Plaats:';
$contact_form_field_url = 'Website:';
$contact_form_field_tel = 'Telefoon:';
$contact_form_field_lat = 'Lat:';
$contact_form_field_lon = 'Lon:';
$contact_form_field_email = 'Uw e-mailadres:';
$contact_form_field_emailname = 'Uw naam:';
$contact_form_field_message = 'Opmerking:';
$contact_form_field_number = 'Validatie nummer:';
$contact_form_field_prompt = 'Validatie nummer';
$contact_form_field_formname = 'Contactformulier';
$contact_form_button = 'Verstuur';
$contact_form_sent = 'Het bericht is met succes verzonden';
$contact_form_not_sent = 'Het bericht is niet verzonden';
$contact_form_invalid_data = 'Vul alle "rood" verplichte velden in.';
?>
<div class="contact_form">
<?php
function contact_form_post($name)
{
return isset($_POST[$name]) ? htmlentities($_POST[$name], ENT_COMPAT) : '';
}
if (isset($_POST['Contact']))
{
if (get_magic_quotes_gpc() && !function_exists('strip_slashes_deep'))
{
function strip_slashes_deep($value)
{
if (is_array($value)) return array_map('strip_slashes_deep', $value);
return stripslashes($value);
}
$_GET = strip_slashes_deep($_GET);
$_POST = strip_slashes_deep($_POST);
$_COOKIE = strip_slashes_deep($_COOKIE);
}
$patern_aux1 = "(\\w+(-\\w+)*)";
$patern_aux2 = "($patern_aux1\\.)*$patern_aux1@($patern_aux1\\.)+$patern_aux1";
$valid_subject = isset($_POST['Subject']) && trim($_POST['Subject']);
$valid_location = isset($_POST['Location' ]) && trim($_POST['Location']);
$valid_name = isset($_POST['Name' ]) && trim($_POST['Name']);
$valid_adres = isset($_POST['Adres' ]) && trim($_POST['Adres']);
$valid_postcode = isset($_POST['Postcode' ]) && trim($_POST['Postcode']);
$valid_city = isset($_POST['City']) && trim($_POST['City']);
$valid_url = isset($_POST['Url']) && trim($_POST['Url']);
$valid_tel = isset($_POST['Tel']) && trim($_POST['Tel']);
$valid_emailname = isset($_POST['Emailname' ]) && trim($_POST['Emailname']);
$valid_email = isset($_POST['Email' ]) && preg_match("/^$patern_aux2$/iX", $_POST['Email']);
$valid_message = isset($_POST['Message']) && trim($_POST['Message']);
$valid_number = isset($_POST['Number' ]) && isset($_SESSION['Number']) && $_POST['Number'] == $_SESSION['Number'];
// verplichte velden die rood en schuin gezet worden
if (!$valid_subject) $contact_form_field_subject = "<em>$contact_form_field_subject</em>";
if (!$valid_location) $contact_form_field_location = "<em>$contact_form_field_location</em>";
if (!$valid_name) $contact_form_field_name = "<em>$contact_form_field_name</em>";
if (!$valid_adres) $contact_form_field_adres = "<em>$contact_form_field_adres</em>";
//if (!$valid_postcode) $contact_form_field_postcode = "<em>$contact_form_field_postcode</em>";
if (!$valid_city) $contact_form_field_city = "<em>$contact_form_field_city</em>";
//if (!$valid_url) $contact_form_field_url = "<em>$contact_form_field_url</em>";
//if (!$valid_tel) $contact_form_field_tel = "<em>$contact_form_field_tel</em>";
if (!$valid_emailname)$contact_form_field_emailname = "<em>$contact_form_field_emailname</em>";
if (!$valid_email) $contact_form_field_email = "<em>$contact_form_field_email</em>";
//if (!$valid_message) $contact_form_field_message = "<em>$contact_form_field_message</em>";
if (!$valid_number) $contact_form_field_number = "<em>$contact_form_field_number</em>";
// verplichte velden die ingevuld moeten worden
if ($valid_location &&
$valid_name &&
$valid_adres &&
//$valid_postcode &&
$valid_city &&
//$valid_url &&
//$valid_tel &&
$valid_email &&
$valid_emailname &&
//$valid_message &&
$valid_subject &&
$valid_number)
{
$error_reporting = error_reporting(E_ERROR | E_PARSE);
// volgorde zoals het in de e-mail komt te staan
$tekst .= "Locatie: $_POST[Location]\r\n";
$tekst .= "Naam locatie: $_POST[Name]\r\n";
$tekst .= "Adres: $_POST[Adres]\r\n";
$tekst .= "Postcode: $_POST[Postcode]\r\n";
$tekst .= "Plaats: $_POST[City]\r\n";
$tekst .= "Website: $_POST[Url]\r\n";
$tekst .= "Telefoon: $_POST[Tel]\r\n";
$tekst .= "Lat: $_POST[Lat]\r\n";
$tekst .= "Lon: $_POST[Lon]\r\n";
$tekst .= "Naam: $_POST[Emailname]\r\n";
$tekst .= "E-mail: $_POST[Email]\r\n";
$tekst .= "Opmerking: $_POST[Message]\r\n";
$subject .= "$_POST[Subject]";
$mail_sent = mail($contact_form_your_email, $subject, $tekst,
"To: $contact_form_your_name <$contact_form_your_email>\r\n" .
"From: {$_POST['Name']} <{$_POST['Email']}>\r\n");
error_reporting($error_reporting);
if ($mail_sent)
echo "<div class=\"error\"><h4>$contact_form_sent</h4></div>";
else echo "<div class=\"error\"><em class=\"error\">$contact_form_not_sent</em></div>";
if ($mail_sent) $_POST = array();
}
else echo "<div class=\"contact_form\"><div class=\"error\"><em>$contact_form_invalid_data</em></div></div>";
}
$_SESSION['Number'] = str_pad(rand(0, 9999), 4, '0', STR_PAD_LEFT);
?>
<html>
<head>
<script type="text/javascript" language="Javascript" src="http://maps.google.nl/maps?file=api&v=2&key=ABQIAAAAFfkqaO0Jn3KjadwVU2kClRTvQnD7WYhfEkTfU7dDbXSM7xa89xSn6tM7QIDCWQ-96jKBE3toIjzW-w" type="text/javascript"></script>
<script type="text/javascript" language="Javascript">
var map = null;
var geocoder = null;
function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
geocoder = new GClientGeocoder();
}
}
function showAddress(address) {
if (geocoder) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + "geen geldig adres gevonden.");
} else {
var map = new GMap2(document.getElementById("map_canvas"));
marker = new GMarker(point, {draggable: true});
map.setCenter(marker.getPoint(), 17);
map.setMapType( G_SATELLITE_MAP );
document.getElementById('lat').value = marker.getPoint().lat().toFixed(6);
document.getElementById('lon').value = marker.getPoint().lng().toFixed(6);
GEvent.addListener(marker, "click", function() {
var point = marker.getPoint();
var lat = document.getElementById('lat').value;
var lon = document.getElementById('lon').value;
var naam = document.getElementById('naam').value;
var adres = document.getElementById('adres').value;
var postcode = document.getElementById('postcode').value;
var plaats = document.getElementById('plaats').value;
var url = document.getElementById('url').value;
var telefoon = document.getElementById('telefoon').value;
var land = document.getElementById('land').value;
var html = ("<b>" + naam + "</b><br>" + adres + "<br>" + postcode + "<br>" + plaats + "<br>" + land + "<br><br>" + url + "<br>" + telefoon + "<br>Lat: " + lat + "<br>Lon: " + lon);
marker.openInfoWindowHtml(html);
});
GEvent.addListener(marker, "dragstart", function() {
map.closeInfoWindow();
});
GEvent.addListener(marker, "dragend", function() {
var point = marker.getPoint();
document.getElementById('lat').value = marker.getPoint().lat().toFixed(6);
document.getElementById('lon').value = marker.getPoint().lng().toFixed(6);
});
map.addOverlay(marker);
}
}
);
}
}
</script>
<style type="text/css">
<!--
table { font-size: 10px;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
-->
</style>
<link rel="stylesheet" href="style-simple.css">
<?php { ?>
<body onLoad="load()" onUnload="GUnload()">
<form name="form" method="post" action="<?=$_SERVER['REQUEST_URI'];?>">
<table width="900">
<tr>
<td colspan="2"><div align="left"><?=$contact_form_field_formname;?></div></td>
</tr>
<tr>
<td width="445"><table width="100%">
<tr>
<th colspan="3"></th>
</tr>
<tr>
<th><?=$contact_form_field_subject;?>*</th>
<td colspan="2">
<p>
<input name="Subject" type="radio" value="toevoeging nieuwe locatie"<?php if ($_POST['Subject'] == 'toevoeging nieuwe locatie') { echo 'checked'; } ?> />
Toevoeging<br />
<input name="Subject" type="radio" value="wijziging locatie"<?php if ($_POST['Subject'] == 'wijziging locatie') { echo 'checked'; } ?> />
Wijziging<br />
<input name="Subject" type="radio" value="verwijdering locatie"<?php if ($_POST['Subject'] == 'verwijdering locatie') { echo 'checked'; } ?> />
Verwijdering
</div></td>
</tr>
<tr>
<th colspan="3">------------------- Locatie informatie -------------------</th>
</tr>
<tr>
<th width="127"><?=$contact_form_field_location; ?>*</th>
<td colspan="2"><div class="input">
<p>
<input name="Location" type="radio" value="green"<?php if ($_POST['Location'] == 'green') { echo 'checked'; } ?> />
Autoclub<br />
<input name="Location" type="radio" value="red"<?php if ($_POST['Location'] == 'red') { echo 'checked'; } ?> />
Vliegclub<br />
<input name="Location" type="radio" value="blue"<?php if ($_POST['Location'] == 'blue') { echo 'checked'; } ?> />
Bootclub<br />
<input name="Location" type="radio" value="gray"<?php if ($_POST['Location'] == 'gray') { echo 'checked'; } ?> />
Winkel </p>
</div></td></tr>
<tr>
<th><?=$contact_form_field_name; ?>*</th><td colspan="2"><div class="input"><input name="Name" id="naam" type="text" value="<?=contact_form_post('Name');?>"></div></td></tr>
<tr>
<th><?=$contact_form_field_adres; ?>*</th><td colspan="2"><div class="input"><input name="Adres" id="adres" type="text" value="<?=contact_form_post('Adres');?>"></div></td></tr>
<tr><th><?=$contact_form_field_postcode; ?></th><td colspan="2"><div class="input"><input name="Postcode" id="postcode" type="text" value="<?=contact_form_post('Postcode');?>" size="10">
</div></td></tr>
<tr>
<th><?=$contact_form_field_city;?>*</th><td colspan="2"><div class="input"><input name="City" id="plaats" type="text" value="<?=contact_form_post('City');?>"></div></td></tr>
<tr><th><?=$contact_form_field_url;?></th><td colspan="2"><div class="input"><input name="Url" id="url" type="text" value="<?=contact_form_post('Url');?>" /></div></td></tr>
<tr><th><?=$contact_form_field_tel;?></th><td colspan="2"><div class="input"><input name="Tel" id="telefoon" type="text" value="<?=contact_form_post('Tel');?>" size="10" />
</div></td></tr>
<tr>
<th colspan="3">------------------- Google informatie -------------------</th>
</tr>
<tr>
<th><?=$contact_form_field_lat;?></th>
<td colspan="2"><div class="input"><input name="Lat" id="lat" type="text" value="<?=contact_form_post('Lat');?>" size="10" readonly="readonly" style="background: #CCCCCC; border: solid 1px; border-color:#999999" /><input name="locatie" type="hidden" value="" size="60" />
</div></td>
</tr>
<tr>
<th><?=$contact_form_field_lon;?></th>
<td colspan="2"><div class="input"><input name="Lon" id="lon" type="text" value="<?=contact_form_post('Lon');?>" size="10" readonly="readonly" style="background: #CCCCCC; border: solid 1px; border-color:#999999"
/><input name="land" type="hidden" id="land" value="Nederland" />
</div></td>
</tr>
<tr>
<th colspan="3">
------------------ Afzender informatie ------------------</th>
</tr>
<tr>
<th><?=$contact_form_field_emailname; ?>*</th>
<td colspan="2"><div class="input"><input name="Emailname" type="text" value="<?=contact_form_post('Emailname');?>"></div></td>
</tr>
<tr>
<th><?=$contact_form_field_email; ?>*</th>
<td colspan="2"><div class="input"><input name= "Email" type="text" value="<?=contact_form_post('Email');?>"></div></td>
</tr>
<tr><th><?=$contact_form_field_message;?></th><td colspan="2"><div class="input"><textarea name="Message" cols="25" rows="4"><?=contact_form_post('Message');?></textarea></div></td></tr>
<tr>
<th><?=$contact_form_field_number;?>*</th><td colspan="2"><div class="input" style="float: left;"><input type="text" name="Number" autocomplete="off">
</div>
</td>
</tr>
<tr>
<th> </th>
<td width="65"><img width="60" height="17" src="<?=$contact_form_image_url;?>?sname=<?=session_name();?>" alt=""></td>
<td width="220"><span class="input" style="float: left;"><small>
<?=$contact_form_field_prompt;?>
</small></span></td>
</tr>
<tr>
<th colspan="3"> </th>
</tr>
<tr><th><input type="button" value="Toon op kaart" onClick="showAddress(this.form.adres.value +', ' + this.form.plaats.value);" /></th><td colspan="2"><input id="submit_contact" class="submit" type="submit" name="Contact" value="<?=$contact_form_button;?>"></td></tr>
</table></td>
<td width="443" valign="top"><div id="map_canvas" style="width: 460px; height: 500px"></div>
<br>
* verplichte velden</td>
</tr>
</table>
</form>
<?php } ?>
</div>
------
<?php
// Copyright (C) 2008 Ilya S. Lyubinskiy. All rights reserved.
session_name($_GET['sname']); session_start();
$t_num = isset($_SESSION['Number']) ? $_SESSION['Number'] : '0000';
if (get_magic_quotes_gpc() && !function_exists('strip_slashes_deep'))
{
function strip_slashes_deep($value)
{
if (is_array($value)) return array_map('strip_slashes_deep', $value);
return stripslashes($value);
}
$_GET = strip_slashes_deep($_GET);
$_POST = strip_slashes_deep($_POST);
$_COOKIE = strip_slashes_deep($_COOKIE);
}
header("Pragma: no-cache");
header("Cache-Control: no-cache");
header("Expires: Fri, 31 Dec 1999 23:59:59 GMT");
header("Content-type: image/png");
$image = imagecreate(60, 17);
$white = imagecolorallocate($image, 255, 255, 255);
$black = imagecolorallocate($image, 0, 0, 0);
imagestring ($image, 3, 13, 2, $t_num, $black);
imagepng ($image);
imagedestroy($image);
?>