This is an old revision of the document!


Field transfer V2

On the basis a local selection a certain email address is to be selected and handed over. Version 02.

Advantages over V1:
The correct case of an error in the select menu “Ortsauswahl” is taken off. Even with a second error input, the focus remains in the drop down box on the previous selection.
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

  • $phpwcms['allow_ext_init'] = 1;



Example:


There are several regions, each is assigned an email address to contact the right person for this region.

  • The region is one of many and can be selected in a pull-down menu. The email address of the contact person is assigned.
  • It often happens that several regions will be managed by one person, thus stored identical email addresses.
  • In the text of the initial email the selected region are shown.

The last requirement excludes the use of the form from PHP function because we can not relate in a typical building a response 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 selects 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 selects. (Obelix is responsible for both places).

Extended Version 2:

FIXME translate

  • Um den Fehlerfall und die Selektion zu ermöglichen verwenden wir ein einfaches Ausklappmenü.
    Die Auswahl kann so in $postvar['ortsauswahl'] bestimmt werden.
  • Die Beziehung zwischen Ortsangabe und eMailadresse wird in dem versteckten Feld “ort_email” abgelegt (Variable $_POST['ort_email']).
  • Für die Ausgabe des Ortes wird ein verstecktes Feld “ort” angelegt (Variable $_POST['ort']).
  • Für die Ausgabe der eMailadresse wird ein E-Mail-Feld “email” angelegt (Variable $_POST['email']) um die “email” als Absender eintragen zu können.

Meiner Ansicht nach müssen für das gewünschte Ergebnis 4 Felder angelegt werden (siehe unten 1-4), da wir ein Eingabefeld (in diesem Fall “ortsauswahl”) nicht während der wiederholten Eingabe (Fehlerfall) manipulieren dürfen. Die Session setzt sonst vorherige Eingabe zurück.
Also wird ein einfaches Eingabefeld verwendet (Artikelmenü) das nicht durch das Script verändert wird. Die Zuordnung der eMailadresse zum gewählten Ort passiert im Script mit der Hilfe eines zweiten versteckten Feldes in dem diese Beziehung abgelegt ist.
Die eMailadresse ist unleserlich abgelegt um SPAM-Robotern keine Gelegenheit zu geben diese als solche auszulesen. (Ort|Name*domain:tld# —> Kleinbonum|obelix*lokal:arpa#). Das Zeichen # dient als Trenner der einzelnen Datensätze und muss angegeben werden.

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).


Script:

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.


Backend:

[selelct 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:

recipient - template

Hallo {anrede} {name},

E-Mail: {email}

Ort:    {ort}

Kommentar:
------------------------------
{kommentar}
------------------------------

Das war alles - Danke.

Template:

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>
english/phpwcms-system/article/contentparts/form/special-applications/php-script-and-function/field-transfer-v2.1279439290.txt.gz · Last modified: 2018/06/03 18:07 (external edit)
www.planmatrix.de www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0