p01-contact

The p01-contact default form

p01-contact is a php script who let you simply create advanced contact forms.

p01-contact is natively a plugin for GetSimple cms.

An example of email received. deprecated image

Live examples

There is hundred of sites using this script, here are some examples :

Installation

  1. For GetSimple, unzip it in plugins/ directory.

Use

As a script

Include the script :

include 'path/to/p01-contact/p01-contact.php';

Create a P01contact instance :

$p01contact = new P01contact();

Define default email address with :

$p01contact->default_email = 'address@domain.ext';

Add form(s) by parsing a string containing tags according to the syntax described below :

echo $p01contact->parse($string);

For example, to display a default contact form :

$p01contact = new P01contact();
$p01contact->default_email = 'address@domain.ext';
echo $p01contact->parse('(% contact %)');

As a GetSimple plugin

In pages

Simply write in a page a tag according to the syntax described below, and a form will appear!

Reminds you to fill the Meta Description, accessible in page options
If you don't, GetSimple will show the tag in the source code of the output page.

In component or template

You can use it everywhere you want by manipulating the variable $p01contact, already initialized.

To parse a string and replace tags by forms, use :

$p01contact->parse($string);

For example, to display a default contact form in your sidebar :

<?php
get_component('sidebar');
echo $p01contact->parse('(% contact %)');
?>

Syntax

The syntax used is really simple, but powerfull.

Simple

The minimum tag is :

(% contact %)

It create a default form (see Default params in settings) destinated to the default email address (see Default email in settings).

In the following, to define some parameters we will follow the word “contact” with a colon :

(% contact : parameters %)

Defining recipients

You can define any recipients you want by adding valid addresses separated by commas, like :

(% contact : address@domain.ext %)
(% contact : address@domain.ext, another@domain.ext %)
(% contact : address@domain.ext, another@domain.ext... %)

Advanced

You can construct your own form by specifying the fields like you specify the recipients :

(% contact : field, field, field... %)

By replacing field by valid fields types and/or fields options.

There is two sorts of fields types : the specials and the generals.

Special fields types

The specials types are fields doing specific actions :

Those ones are used in mail :

  • name : a text field used as source name in email. If it's not used, the sender name will be “Anonymous”.
  • email : a text field with email form verification, used as source address in email. If it's not used, the sender email will be “anonymous”.
  • subject : a text field used as subject in email. If it's not used, the subject will be ”(No subject)”.

Those ones have a verification of their format :

  • phone : a text field with phone number format verification.
  • website : a text field with web address format verification.
  • message : a textarea with minimum text length verification.

Those ones protect your forms :

  • captcha : a reloadable capcha image with text field entry verification.
  • fieldcaptcha : a simple and integrated capcha system. Add a field with mention do not fill this field. If the field is filled, it's a robot. :p
  • password : Check if input value is equal to required value.

And there is this one too :

  • askcopy : a checkbox allowing the user to receive a copy of the email.

General fields types

These fields are not doing anything special, but they are displayed in mail content.

  • text : a text field, for short information.
  • textarea : a textarea field, for longer information.
  • checkbox : one or more check boxes and labels. Several may be checked.
  • select : a drop down list with defined values.
  • radio : one or more radio buttons and labels. Only one may be checked.

Unknown fields types

If you enter an unknown field type, no field will be displayed but its name will be displayed and mentioned in <div> class :

(% contact : something %)
<div class="field something">
    <div class="label">
        <label>The title</label>
    </div>
</div>

Use that to create separations texts, titles, answer/response…

(% contact : answer "This is an answer", response "This is the response" %)
/* apply to every fields */
.p01-contact .field{margin:5px;}
/* those are known fields */
.p01-contact .text{margin:5px;}
.p01-contact .captcha{margin:10px;}
/* those are user-defined fields (labels only) */
.p01-contact .answer{color:red;}
.p01-contact .response{color:blue;}

Fields options

  • An exclamation point after the field type define it as required, like :
    message!

    A required field left empty will display a “This field is required” error.

  • A text between quotes define field title, like :
    message "Tell me something :"
  • A text after an equality symbol define field pre-filled value, like :
    message = value

    Except for password field, where that define required value :

    password = required value

    For multiple values fields, separate values by vertical bars :

    checkbox = "value1" selected | "value2" selected | "value3"
    select = "value1" | "value2" selected | "value3"
    radio = "value1" | "value2" | "value3" selected

    Note the use of selected keyword to define selected value(s).

  • A text after an arrow symbol define field locked value, like :
    message => value

    Works with multiple values fields :

    select => "value1" | "value2" selected | "value3"

Place multiple options in this order :

fieldType! "title" => value

Tags examples

Default :

(% contact %)

Default with defined recipients :

(% contact : recipient@domain.ext, other@domain.ext %)

Advanced form construction :

A minimal one :

(% contact : email!, message! %)

A big one :

(% contact : address@domain.ext, another@domain.ext,
             subject => About this script,
             email!,
             textarea "How old is born Napoléon?",
             phone,
             radio "Do you like this script?" = "Yes" selected | "No", 
             website,
             select = "One" selected | "Two" | "Three" | "Four" | "Five" ,
             message = Say something!,
             password = tomato,  
             captcha, 
             askcopy %)

Settings

You can display a functionnal configuration panel with :

echo $p01contact->panel();

In GetSimple, simply access to it from the admin panel, in the Plugins tab :

Enable

When disabled, the forms are displayed and all the process are executed (fields verifications, etc…) but finally, instead of sending the mail a message “Plugin disabled” is displayed.

Default email

Define email used for default froms. Default email can also being set with :

$p01contact->default_email = 'email@domain.ext';

This is indicated in italic below. (for GetSimple, this is set to admin email)

Settings default address prevails to that defined in code.

To send a mail, a form need at least one valid recipient defined in tag, or a valid default email defined in code or a valid default email defined in settings.

Language

Default language is by default to English, and can be set with :

$p01contact->default_lang = 'fr';

For GetSimple, default is the language defined in GetSimple.

You can also define to use a particular language, by selecting one in the list of existing translations. Those beginning with ”~” are not fully translated.

Messages minimum length

Minimum number of characters to write in message fields to be valid.

This setting does not affect the textarea fields.

Default parameters

This setting let you defining the form structure used when no structure has been set in tag, in other words default tags.

Use the form construction syntax described above.

Fields checklists

Blacklist : indicating values that must not be present in the field to send email.
Whitelist : indicating possibles values required for the field to send email.

All values must be separated by commas.

Debug mode

The debug mode disable mail sending and display p01-contact object data structure. If a form is posted, it display data sent and the email that would have been sent.

Translations

Included translations

The last stable version is translated in :

  • Dutch 45%
  • English
  • French
  • German
  • Italian 45%
  • Russian 45%
  • Spanish 45%
  • Swedish 45%

The development release is already translated in :

  • Bulgarian
  • Dutch
  • English
  • Finnish
  • French
  • German
  • Hebrew
  • Italian
  • Lithuanian
  • Polish
  • Portuguese
  • Russian
  • Spanish

Some translations are not complete, and will not be included in the next stable release :

  • Swedish 45%

Thanks to Martin Köhler, Carlos Navarro, Kristian Salonen, Nicola Sarti, Vaidotas Kazla, Thomas Stolwijk, Evandro Xavier Azevedo, Eugene Vetrov, Göran Söderberg, barlew, Iggy Pritzker, Panayot Kuyvliev and Daniel A. Rodriguez.

How to translate?

Attention : the successor of p01-contact, FormSimple, is comming very soon and require different translations. Please check it before doing unnecessary work.

  1. Go to :
    p01-contact/lang

    (Use development release : there is probably some translation changes since the stable one.)

  2. Duplicate an existing file fully translated (in the language that you understand more easily) and rename it with the new language code, according to ISO 639-1. Example : for japanese, rename it to jp.php.
  3. Open the new file with a text editor and translate the sentences after the arrows :
    'sentfrom' => 'Translate me here',
  4. Change the file header to indicate the language used and your name. Example, for japanese :
    /**
     * Japanese language file
     * @author Your Name
     * @package p01-contact
     */
  5. Please send me your translation, so I integrated it into the next version!

Changelog

0.9.1

2010-11-06
Download 0.9.1.zip.

  • Full german translation
  • Bugs fix : captcha verification and reload
  • Url to captcha defined with GS $SITEURL (should work with url rewriting)
  • Captcha required by default (default params with captcha!)
  • Languages names instead of ISO codes in configuration panel (new lang/langs.php file, associating iso and name).

0.9

2010-11-05
Download 0.9.zip.

  • New special field : fieldcaptcha.
  • New special field : password.
  • New special fields : checkbox, select and radio.
  • Security : implementation of sessions tokens.
    • Prevent from history back.
    • Prevent from reload.
    • Prevent from Cross Site Forgery Requests.
  • Script fully separated from GS.
    • p01-contact can be used anywhere.
    • p01contact_gs.php do the link with GS.
  • Configuration panel sentences and info messages added to language system.
  • New setting : default email. Editable by code and settings.
  • Editable default lang.
  • Blacklist/Whitelist choice prepared.
  • General fields have checklists too.
  • HTML/CSS structuration.

0.8

2010-10-30 to 2010-11-02
Download 0.8.3.zip or 0.8.2.zip or 0.8.1.zip or 0.8.zip.

  • Fully object oriented recoded.
    • Unlimited multiple parsing.
    • Unlimited fields manipulation.
  • Debug mode.
  • Plugin last version check (Extend API).
  • Italian, russian, spanish translations.
  • Possible translations are listed in admin panel.
  • Many bugs fixes and improved functioning.

0.7

2010-10-27
Download 0.7.zip.

  • Administration panel. Accessible in “Plugins → p01-contact”.
  • Fields editable blacklists. Some anonymous-webmails included.
  • Message minimum length setting.
  • Default form stucture is simply defined by default tag parameters.
  • Use/mimics fancy GetSimple info messages.
  • Field label bug with multiple forms fixed.
  • Captcha reload bug fixed.

0.6

2010-10-25
Download 0.6.zip.

  • Separated languages files.
  • Separated config file.
  • Doc-commented code.
  • Main function is now simply “p01contact”.
  • Links to this page, GS extend and GS forum in plugin description.

0.5 and before

  • 0.5.zip 2010-10-17
    • Tag-with-no-options allowed : the recipient is the administrator address.
    • Clarifying use and process.
    • New special field : askcopy.
    • New special field : website.
    • Allow adding not-special fields : checkbox, text, textarea.
    • Configurable field name.
    • Configurable field value (pre-fill).
    • Configurable field locked-value (not editable value).
    • Use by default GS installation language.
    • Don't parse plugin tags in code tag.
    • Output in div, not tables.
  • 0.4.zip 0.4.1.zip 0.4.2.zip 2010-10-10 to 2010-10-12
    • Encoding fixed : every language is supported.
    • Tags parameters controls recipients and options.
      • Add multiple recipients,
      • Display fields,
      • Hide fields,
      • Make fields required.
    • Page form ID : query associated to specific tag during process.
    • Multiple forms system.
    • Bugs fixes.
  • 0.3.zip 2010-10-09
    • Define what fields to show, in what order.
    • Define what fields are required to send email.
    • New CAPTCHA field.
    • Setup system ready for tag parameters.
    • Dynamic error system, content validation and form generation.
    • Bugs fixes
    • multi-language support
    • w3c validation
    • Bugs fixes
  • 0.1.zip 2010-10-08

Todo

I list here the new functionalities and changes expected before the 1.0. Fell free to tell me if you have a cool idea, or if you know how to realise one :

Coded, in next release
  • Any forms actions possibles. The actual only integrated action is send_mail (send a mail with form answers to recipients), but anything is now possible (pool, newsletter, comments…).
  • Hide every fields by using ? :
    fieldType?
  • Multipart/alternative mail content : plain text and html.
  • Fix : two unlocalized strings “Save settings” and “Default” in admin settings.
  • Checklists can be defined as blacklist or whitelist.
Todo
  • Remove paragraph wrapped around tag. See
  • license.txt and documentation.txt.
  • Make a better phone pattern.
  • Multiple values allowed for fields treated as text (create selection list).
  • Attachment field. Infos here, here or here. For multiples files types accepted (like by black/whitelist), MIME type management needed; or force one, like zip.
  • Home-made anti-bot. What is better? An integrated literal captcha system (removing the directory p01contact/captcha) but fairly easy to circumvent, or current advanced captcha image?
  • Set the page meta description if it's left empty to prevent GS page source scan. How to modify $metad?
Possible or known bugs
  • Mail subject encoding. See
  • B/W lists bug. See
  • Quote in email pattern (o'reily bug). See

Discussion

Etienne, 2010/10/20 00:36

Bonjour,

Est-il possible d'utiliser ton plugin ailleurs que dans la partie “Pages” de GetSimple ? En essayant de l'utiliser dans un composant ou directement dans le code php du thème, j'ai seulement un ”(% contact %)” qui s'affiche sur la page de mon site. Y a-t-il un moyen d'arranger cela ?

Merci.

Etienne

Nicolas, 2010/10/23 17:59

Bonjour,

C'est une très bonne question, j'ai rajouté l'information dans la documentation “Use the plugin outside a GS page”.

Merci à vous.

twix, 2010/11/11 23:22

bonsoir, est-il possible d'utiliser un select dans le sujet (choix du sujet de l'email selectionnable dans une liste déroulante)? merci pour ce plugin

Nicolas, 2010/11/14 23:17

Bonsoir,

Ravi que cela vous plaise.

Vous pouvez créer une liste déroulante titrée “Sujet” à la place ou en plus d'un champ subject, du type :

select "Sujet" = "Un sujet" | "Un autre" | "Un dernier"

La valeur choisie sera indiquée dans le mail envoyé mais ne sera pas utilisée en tant que sujet dudit mail.

Une prochaine release permettra peut-être l'utilisation de valeurs multiples pour les champs de texte, si cela s'avère nécessaire.

Ian, 2010/12/15 17:18

Quand je recois un emaiil avec Thunderbird je vois un tas de HTML avec le message. Est il possible de supprimer ce format pour que le mail envoyee ne contient que le message?

Nicolas, 2010/12/17 16:01

Bonjour,

Pour l'instant le script ne permet l'envoi de messages qu'en html. Vous pourrez toutefois arriver à vos fins en modifiant directement le mail envoyé par la fonction send_mail() ligne 647 de p01-contact.php (remplacer le Content-type du header en text/plain et virer toutes les balises html que vous croisez).

A terme le format de sortie pourra être défini.

PP, 2011/01/05 10:51

Bonjour et merci pour votre plugin. Je l'ai installé sur mon site. Est-il néanmoins possible de modifier la taille et la disposition des champs du formulaire ? Peut-on le faire à même le code (dans le fichier Php) ? Prévoiriez-vous une possibilité de modifier la taille du champ Message à même le panel, de sorte qu'on puisse l'adapter à la largeur de sa div ou de sa page par exemple ?

Nicolas, 2011/01/13 23:09

Bonsoir et merci.
Il est tout à fait possible de modifier de n'importe quelle manière l'aspect des formulaires au moyen de feuilles de style (CSS). Le plugin ne fait que générer une structure de données html.
Il n'est pas nécessaire de modifier le code source du plugin pour une utilisation standard.

albertuan, 2011/01/20 17:45

Hi,
I would like to use your plugin in a Get Simple site.
How can I change language on the fly: need to do different languages contact page.
Please help
Thanks

Nicolas, 2011/01/22 17:52

Hi,
You can change script language with :

$p01contact->default_lang = 'fr';

Cf. settings → Language
Of course you need to detect user language, like with :

echo $_SERVER['HTTP_USER_AGENT'];
madvic, 2011/01/26 15:33

Bonjour,

Je viens de remarquer un souci. Quand le plugin exac-php est installé, le plugin contact ne fonctionnne plus. Cdlt

Igor, 2011/01/27 20:45

Hello!

I need to change the email which is sent i wanna add to the email who sent it and their email adress like this

Fromsite site.com Wed, 26 Jan 2011 21:18:54 +0100 From: Sender NAme Sender email: something@some.thing Message :

This is an a test mail…This is an a test mail…This is an a test mai

Sentfrom /index.php?id=contact If this mail should not be for you, please contact email@gmail.com

Nicolas, 2011/01/28 14:15

Bonjour madvic. C'est noté merci, je ne me suis pas encore penché sur la question.

Hi Igor. What adress would you change? The “please contact” one? There is no other way than modify the source code. You need to adapt the function send_mail() starting line 647 in p01-contact.php.

Igor, 2011/01/28 14:45

Thank you for the fast response, actually i just wanna change the message in this way:

here is the message which is written by the user and i want to add their email adress and name

at php at line 681 there is the box and the message but i dont know how to add sender email and sender name

case 'textarea' :
$content .= '<p style="margin:10px;padding:10px;border:1px solid silver">';
$content .= nl2br($value) . '</p>';
break;

should i add just something like this:

$content .= '<p>'
$content .= $email . '</p>'
Nicolas, 2011/01/28 18:04

Hi,

Name and email fields are avoided in mail content because they are already indicated in mail header. If you want to write them anyway, you can change the elseif condition at line 667 by an if condition :

if($type == 'subject')
Chris, 2011/03/29 15:04

Thank you for really nice plugin. I used it on my work. http://www.jp-transport.pl/kontakt/

Nicolas, 2011/04/05 14:29

I'm glad you like it! Your website is shown in Live examples.

Compagnon, 2011/04/08 10:17

Bonjour,

Comment faire pour ne pas exiger que les champs soit obligatoires ?

Merci beaucoup pour ce plugin!

Nicolas, 2011/04/09 19:48

Bonjour,

Les champs ne sont pas requis par défaut, l'utilisation du point d'exclamation permet de les rendre obligatoires. Cf. Fields options.

Costas Lazarou, 2011/04/17 16:10

My apologies for witting in English, I did not use my French for over 50 years, but I can still read and understand. Thank you for the excellent plugin to Get Simple which I am using in my site http://www.helcan.com/contact-us/ with some minor modification only in the Captcha area.

I would like to make all entry text areas quite a bit wider, but I am lost. When I changed the pO1-contact.php from width 100% to 600 px nothing happened, so I reverted back. Your help will be greatly appreciated, et je vous remercie

Costas

Nicolas, 2011/04/28 15:34

Hi, glad you like it.

This plugin do not offer a form styling, only the html construction : so you have to edit the css, not the script source.

I'm linking to your post in GS forum, for a complete answer : http://get-simple.info/forum/topic/1758/one-more-contact-form-question

Scott, 2011/04/19 23:00

Hello,

I keep getting:

Notice: Undefined index: p01-contact in /homepages/37/d247828499/htdocs/admin/plugins.php on line 31

in admin/plugins with no config settings for the plugin p01-Contact.

Has anyone seen this?

Nicolas, 2011/04/28 15:37

Hi. Obviously GS doesn't see the plugin. Try to delete/reinstall it.

Entrer votre commentaire