[Tutorial] php form mail script.

phpBB3 and MOD challenges setup by the staff to test and challenge your phpBB3 coding skills.

Rate this tutorial

Excellent!
1
50%
Very good
1
50%
Good
0
No votes
Fair
0
No votes
Poor
0
No votes
 
Total votes : 2

[Tutorial] php form mail script.

Postby Handyman » 09 Jun 2007, 20:04

If you have searched for php form mail scripts, you probably have noticed the lack thereof.
Most are usually CGI, Perl or some other chaotic programming language ;)

So here is my php version that works with any form as long as you have a few certain things in place? which hopefully I will explain well enough for anybody to understand.

HTML
First, in your html form? make sure the form tag looks something like this:
Code: Select all
<form action="./formmail.php" enctype="application/x-www-form-urlencoded" method="post">

make sure to change ./formmail.php to the path to the php form mail script.

Then your form can be any way you like it? until the end.
Here is how the end of the form works.

Change abc to code setup for recipient in formmail.php.
Code: Select all
<input type="hidden" name="rcp" value="abc" />


Change abc to code setup for tld in formmail.php
Code: Select all
<input type="hidden" name="tld" value="abc" />


Change "this page" to the name of the page this is submitted from? for your reference.
Code: Select all
<input type="hidden" name="location" value="this page" />


Change "my subject" to the subject you want the email to say when it reaches your inbox
Code: Select all
<input type="hidden" name="subject" value="my subject" />


Change ./thanks.php to a page you have setup to display a successful submission message
Code: Select all
<input type="hidden" name="redirect" value="./thanks.php" />


Only change the value to whatever you want displayed on the submit button.
Code: Select all
<input type="submit" name="submit" value="Submit" />


Now that you have your html form in place? time for the php to take over.

I'm attaching formmail.php
Please note the 2 areas that need to be edited for this to work:
$recipient_array and $domain_array

formmail.php.zip
(1.73 KiB) Downloaded 212 times


Let me know if this helps or needs to be clarified. :yahoo:
Enjoy! :)

As always, if you use this, please either link back to startrekguide.com or donate to startrekguide.
Please contact me if you have any news to submit to SCOFF News.
SCOFFing at the candidates while you sleep.
My Mods || My Mod Queue
Image
User avatar
Handyman    
Rear Fleet Admiral
Rear Fleet Admiral
 
Posts: 7456
Joined: 08 May 2006, 04:45
Location: Where no man has gone before!
Favorite Team: Seattle Seahawks
Gender: Male




phpBB Academy at StarTrekGuide
Support STG
Using PayPal Donate

Re: [Tutorial] php form mail script.

Postby topdown » 03 Nov 2007, 23:46

I'll give you two thumbs up bud. :good: :thumbsup:

You are very correct that php mail scripts are hard to come by.
I did a lot of searching to find the one that I use and after reading your layout and code seems to be very similar.

Anyway, excellent tut. :cool:
Do not PM me for Support unless I give permission in a post......PM's only help one, posts help everyone !
User avatar
topdown    
STG Styles Leader
STG Styles Leader
 
Posts: 3026
Joined: 01 Oct 2007, 22:56
Location: Handyman's harddrive
Favorite Team: STG Teams
Gender: Male
phpBB Knowledge: 9

Re: [Tutorial] php form mail script.

Postby JIGzZ » 04 Nov 2007, 14:31

very useful for newbie
thank you Sir ... :)
JIGzZ
Cadet I
Cadet I
 
Posts: 16
Joined: 31 Oct 2007, 03:37
Location: Karachi, Pakistan
Gender: Male

Re: [Tutorial] php form mail script.

Postby poppertom69 » 07 Jan 2008, 10:00

Yeah i had to make my own mailing script for a mailing list for an estate agent to show all there new properties that week, I find it much better using your own know where it goes wrong then!
Image
Image
poppertom69    
Supporter
Supporter
 
Posts: 326
Joined: 13 Apr 2007, 08:08
Location: bucks, UK
Favorite Team: STG
Gender: Male
phpBB Knowledge: 8

Re: [Tutorial] php form mail script.

Postby Tempus1 » 07 Jan 2011, 12:07

Not bad but fairly small and lacking a bit more explanation and funtionality in my opinion.

I wrote one on my forum as I had some people asking about forms. You can read it here - [link removed]

There is also an additional tutorial that explains how to stop spam mail, make forms secure etc. You can find it here - [link removed]

Let me know what you think. Register and vote on the Poll.
User avatar
Tempus1
Crewman
Crewman
 
Posts: 7
Joined: 20 Dec 2010, 12:16
Gender: Male
phpBB Knowledge: 5

Re: [Tutorial] php form mail script.

Postby Obsidian » 09 Jan 2011, 21:19

For future reference, using something like this is a lot more powerful: http://swiftmailer.org/
うるさいうるさいうるさい!

StopForumSpam Spam Reporting Database
Giving xrumer and friends a great big "screw you" since 2007.
User avatar
Obsidian    
Supporter
Supporter
 
Posts: 2250
Joined: 04 Mar 2008, 23:35
Gender: Male
phpBB Knowledge: 10

Re: [Tutorial] php form mail script.

Postby Dragosvr92 » 19 Apr 2011, 07:30

How do you add this to phpbb?
i know how to add a extra page to phpbb but im not sure if im allowed to use php in the php file and load it in the themplate O-o
Previous username: TheKiller
Avatar on Memberlist 1.0.3

Image
User avatar
Dragosvr92    
MOD Author
MOD Author
 
Posts: 362
Joined: 26 Sep 2009, 10:32
Location: Romania
Gender: Male
phpBB Knowledge: 3


Return to phpBB3 Challenges at phpBB Academy

Who is online

Users browsing this forum: No registered users and 1 guest