Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Mailer Script (solution, not problem)

Featured Replies

Ok lads and ladies.

 

I am aware that some people are not scripters, so I though I would help y'all out.

 

There are 4 files here, of which 2 are to show an example...

 

So the files:

* email.html - an example form

* thankyou.html - the default "redirect" page.

 

* mailer.php - the target for your forms NO EDITING REQUIRED

* email.ini - where all your settings are held

 

so what is this used for?

simply put, its a fast and easy way to secure a FORM with some basic regexs (no experience required) and other stuff...

 

how does it work?

the FORM submitted to mailer.php is compared to the defined values in email.ini, and shown as such.

 

how does it secure the form?

in two ways:

1. you specify the type of content expected ( "mixed", "numbers" or "email" ), and the script checks them against this value. If it doesn't match, it isn't used.

 

2. the FORM only uses submitted data which has been named in the INI file.

 

so how would I write the INI file?

lets say we have this form:

Full Name <input name='fname' />
Occupation <input name='job' />
Email Address <input name='email' />
Do you have a cat? <input type='radio' name='hascat' value='yes' /> Yes <input type='radio' name='hascat' value='no' /> No

 

simple really... now the INI file:

[settings]
sendto = richthegeek@googlemail.com
subject = Contact Form
redirect = thankyou.html

[fname]
display = Full Name
value = mixed

[job]
display = Their Job
value = mixed

[hascat]
display = Has a cat?
value = mixed

[email]
display = From
value = email
isfrom = true

 

thats it... just submit the form to mailer.php and you will send a message to the "sendto" address like this:

 

Full Name: Richard Lyon
Their Job: Developer
Has a cat?: no
From: php_penguin@hotmail.com

 

if you change the order in which the sections occur, the email will change to match.

 

very simple to set up, very easy to understand... helpful?

email.zip

This is SO useful! Many thanks, php_penguin.

 

I'll second that :clapping:

 

Really useful information.

 

Thanks Penguin

  • Author

hi thomas....

 

attached an updated version, which allows "error messages" (see INI and HTML for example)

 

The script contains 3 different regex's:

- "Mixed" - allows letters, numbers, and a few standard characters

- "Numbers" - allows numbers + whitespace

- "Email" - allows a valid email address

 

a possible improvement is the option to provide custom regex's (eg exactly 4 numbers).

 

the "send to" address is stored in the INI file and is unchangeable by the user.

 

from my testing, it seems pretty secure - and no PHP knowledge is required.

email.zip

ah, yea. I see. the regex prevents any header injections.

 

Nice script.

I wasn't aware there was a parse_ini_file functions. (though I should have figured)

/me goes to update one of his scripts...

  • Author

yes, there is a built in function for reading+parsing INI files.

 

what i meant was that at the start of writing the mailer script, I forgot that there was a built in function, and so wrote my own version - I attached it so people could see how it might be implemented.

  • 3 months later...

This is very helpful, :-)

 

How would i go about inserting radio buttons and getting them validated too?

  • Author

hi mark,

 

radio buttons have a value of "1" or "0" if no value is set, so you can validate against that (use "/^1/" for the regex).

 

to add a validation you need to change the INI file, which shouldn't be too hard. Bear in mind that it is a while since I wrote this so adding the validation regex might not even work.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.