NAVIGATION
This is an old revision of the document!
Based on a local selection a certain email address is selected and passed over. Version 02.
Advantages over V1:
The complete case of an error in the select menu “Ortsauswahl” will be covered. Even if a second incorrect input is following a first one, the focus will remain in the drop down box previously selected.
The e-mail addresses are included in encoded form to give SPAM robots no selection possibility.
Docu: –
Forum: –
Author: K.Heermann (flip-flop) (16.07.2010)
CMS-Version: >= V1.4.1 r282
Version: V2.0 16.07.2010
Condition: → /config/phpwcms/conf.inc.php
There are several regions, each is assigned an email address to contact the right person for this region.
The last requirement will exclude the use of PHP function within the form because with a standard form setup we cannot build a feedback relation to the selected region. ($postvar['email'] ⇒ test@example.com) if e.g.
[select email menu] Name: email
Bitte wählen -|- Babaorum -|- obelix@lokal.arpa Laudanum -|- obelix@lokal.arpa Kleinbonum -|- asterix@lokal.arpa Aquarium -|- idefix@lokal.arpa
If the user is selecting one of the first two places e.g. “Laudanum”, an identical e-mail address is returned to us, we do not know which location the user has been selecting. (Obelix is responsible for both places).
Extended Version 2:
translate
To my opinion we have to create 4 fields to get the desired results (see below, 1-4) because we must not manipulate an input field (in this case “ortsauswahl”) any further (accidentally) in case of repeated input (case of error/reload), otherwise the session will reset an input made previously.
Therfore we'll make use of a simple input field (Articlemenu) which will not be changed through the script. The script will assign the eMail address to the chosen place with the help of s second hidden field where this relation is defined.
This eMail address is stored fairly unreadable to prefvent SPAM-bots from reading them. (Ort|Name*domain:tld# —> Kleinbonum|obelix*lokal:arpa#). The #- sign is used as a between the different data and has to be set.
Um den Ort im Ausgabetext zu verankern legen wir ein verstecktes Feld “ort” mit dem Inhalt “nix” an. Dieses Feld kann auch zur Identifikation des Formulars dienen, denn das frontend_init-Script wird bei jedem Seitenaufruf abgearbeitet!
Die eMailadresse wird im Script in das Feld “email” übergeben und kann so optional auch als Absenderadresse im Formular eingetragen werden (Mit versteckten Feldern geht das nicht).
E.g.
if( isset($_POST['ort']) AND isset($_POST['ort_email']) ) { ...
So kann das Formular zumindest rudimentär identifiziert werden. Dies kann bei mehreren Formularen in der Site wichtig sein.
Der letzte Schritt ist die Filterung des Ortes und Zuweisung zur Variablen “$_POST['ort']” und “$_POST['email']”.
form_script_email_to_location_v2.php
<?php /** ********************************************************************************************* * 16.07.2010 KH: http://planmatrix.de V2 * frontend_init-Script: Manipulating the e-mail address * - Determining the location and email address in form ********************************************************************************************* */ // ------------------------------------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); } // ------------------------------------------------------------------------------------------- if( isset($_POST['ort']) AND isset($_POST['ort_email']) ) // The right form? { $ort_email = array(); $ort = trim($_POST['ortsauswahl']); // Nur ort enthalten $ort_email = explode('#', $_POST['ort_email']); // // location|text*domain:tld if (!empty ($ort_email)) foreach ($ort_email as $key=>$value) { // --- location|text*domain:tld $split =preg_split('/\|/', $value, 2); // Cutting out the location if (trim($split[0]) == $ort) { $_POST['ort'] = $ort; // assign the location // Cutting out and assign the eMail $_POST['email'] = trim(preg_replace('/(.*)\|(.*)\*(.*):(.*)/is','$2@$3.$4', $value)); break; }; } } // ---- END if( $_POST['ort'] ?>
The right location is passed to the form.
[select menu] Name: ortsauswahl
Bitte wählen-|- Babaorum Laudanum Kleinbonum Aquarium
[hidden] Name: ort_email
Babaorum|obelix*lokal:arpa# Laudanum|obelix*lokal:arpa# Kleinbonum|asterix*lokal:arpa# Aquarium|idefix*lokal:arpa#
[hidden] Name: ort
nix
[e-mail] Name: email
nix
recipient - template:
Hallo {anrede} {name},
E-Mail: {email}
Ort: {ort}
Kommentar:
------------------------------
{kommentar}
------------------------------
Das war alles - Danke.Template:
<!--form-spezial//-->
<div style="width:500px; margin: 0; padding:10px; border:1px solid #bbb; background: #C2E7EF;">
{ERROR:anrede}[B]{LABEL:anrede}[/B] *[BR]{anrede}[BR][BR]
{ERROR:name}[B]{LABEL:name}[/B] *[BR]{name}[BR][BR]
{ERROR:ortsauswahl}[B]{LABEL:ortsauswahl}[/B] *[BR]{ortsauswahl}[BR][BR]
{ERROR:kommentar}[B]{LABEL:kommentar}[/B][BR]{kommentar}[BR][BR]
{ERROR:nospam}[B]{LABEL:nospam}[/B] *[BR]{nospam}[BR][BR]
{submitIt}
</div>