email form needs sending to two contacts

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
shanman
-


Joined: 14 Apr 2003
Posts: 5

PostPosted: Mon Apr 14, 2003 10:51 am    Post subject: email form needs sending to two contacts Reply with quote

Can anyone help me please. I need to submit data from this form to two addresses. Can anyone help me get this sent to person2 as well please. Many thanks

<?php
$msg = "TD Name:\t$name\n";
$msg .= "Tournament ID:\t$tid\n";
$msg .= "Disqualified Players ID:\t$pid\n";
$msg .= "Disqualified Players Username:\t$pname\n";
$msg .= "Reason for disqualification:\t$reason\n";
$msg .= "Round disqualified in:\t$round\n";
$msg .= "Bux to be debited:\t$todebit\n";
$recipient = "person1@yahoo.co.uk";
$subject = "Sub Report";
$mailheaders = "From: The Pond <> \n";
$mailheaders .= "Reply-To: $email\n\n";
mail($recipient, $subject, $msg, $mailheaders);
?>

Many thanks


Last edited by shanman on Mon Apr 14, 2003 2:38 pm; edited 1 time in total
Back to top View user's profile Send private message
WhiteDevil
-


Joined: 07 Oct 2002
Posts: 74
Location: United Kingdom

PostPosted: Mon Apr 14, 2003 11:47 am    Post subject: Reply with quote

if you mean you need a form processor then i recommend using:

EZ FormMail

Code:
<?
###########################################################
# Product:   EZ FormMail                                  #
# Author:    Sensation Designs                            #
# Version:   1.0                                          #
# Released:  March 10, 2003                               #
# Website:   http://www.sensationdesigns.com              #
# Copyright: Sensation Designs. All rights reserved.      #
###########################################################

###########################################################
# NOTE:                                                   #
#                                                         #
# All copyright information, credit, and links to any     #
# pages from Sensation Designs MAY NOT be modified,       #
# removied, or altered in any other fashhion.             #
###########################################################

###########################################################
# This program is free software; you can redistribute it  #
# and/ormodify it under the terms of the GNU General      #
# Public License as published by the Free Software        #
# Foundation; either version 2 of the License, or (at     #
# your option) any later version.                         #
#                                                         #
# This program is distributed in the hope that it will be #
# useful, but WITHOUT ANY WARRANTY; without even the      #
# implied warranty of MERCHANTABILITY or FITNESS FOR A    #
# PARTICULAR PURPOSE. See the GNU General Public          #
# License for more details.                               #
#                                                         #
# You should have received a copy of the GNU General      #
# Public License along with this program; if not, write   #
# to the Free Software Foundation, Inc., 675 Mass Ave,    #
# Cambridge, MA 02139, USA.                               #
###########################################################


###########################################################
# CONFIGURE THE FOLLOWING VARIABLES                       #
###########################################################

// Recipient of message (This can be changed via the form itself)
$recipient = 'you@yourdomain.com';

// Subject of message (This can be changed via the form itself)
$subject = 'WWW Form Submission';

// This is a list of domains that can run EZ FormMail. Do not include
// www, just the actual domain/ip address!
$referers = array('domain1.com', 'domain2.com', 'domain3.com');

// This is the page that users will be redirected to after the form is
// processed successfully.
$success_url = 'http://www.yourdomain.com/thanks.html';

// Your site URL
$siteurl = 'http://www.yourdomain.com';

###########################################################
# DO NOT EDIT BELOW THIS LINE                             #
###########################################################

function Print_Footer() {
   echo '<p><center>Powered by EZ FormMail. Get it <b>free</b> from <a href="http://www.sensationdesigns.com">http://www.sensationdesigns.com</a>!</center>';
}

function Check_Referer() {
   global $referers;
   $temp = explode('/', $_SERVER['HTTP_REFERER']);
   $referer = $temp[2];
   $found = false;
   foreach ($referers as $domain) {
      if (stristr($referer, $domain)) { $found = true; }
   }
   return $found;
}

if ($_POST) {
   if (Check_Referer() == false) {
      echo '<font size="+1" color="#FF0000">Error: Invalid Referer</font><BR>';
      echo 'You are accessing this script from an unauthorized domain!';
      Print_Footer();
      die();
   }
   $ctr = 0;
   
   $isrealname = 0;
   $isemail = 0;
   
   foreach ($_POST as $key => $val) {
      if ($key == 'realname') { $isrealname = 1; }
      if ($key == 'email') { $isemail = 1; }
      if (substr($key, 0, 4) == 'req_' || $key == 'realname' || $key == 'email') {
         if ($val == '') {
            if ($ctr == 0) {
               echo '<font size="+1" color="#FF0000">Error: Missing Field(s)</font><BR>';
               echo 'The following <i>required</i> field(s) were not filled out:<BR>';
            }
            echo '<BR>- <b>'.substr($key, 4).'</b>';
            $ctr++;
         }
      }
   }
   if ($ctr > 0) {
      echo '<p>Click <a href="javascript:history.go(-1)">here</a> to go back';
      Print_Footer();
      die();
   }
   else {
      if ($isrealname == 0) {
         echo '<font size="+1" color="#FF0000">Error: Missing Field</font><BR>';
         echo 'No "realname" field found.<p><a href="'.$siteurl.'">here</a> to return to the home page.';
         Print_Footer();
         die();
      }
      elseif ($isemail == 0) {
         echo '<font size="+1" color="#FF0000">Error: Missing Field</font><BR>';
         echo 'No "email" field found.<p><a href="'.$siteurl.'">here</a> to return to the home page.';
         Print_Footer();
         die();
      }
   }
   
   if (!(preg_match("/^.{2,}?@.{2,}\./", $_POST['email']))) {
         echo '<font size="+1" color="#FF0000">Error: Invalid E-mail</font><BR>';
         echo 'The e-mail address you entered (<i>'.$_POST['email'].'</i>) is invalid.';
         Print_Footer();
         die();
   }
   
   $body = "Below is the result of your feedback form. It was submitted on:\n".date('l, F jS, Y').' at '.date('g:ia').".\n";
   
   foreach ($_POST as $key => $val) {
      if ($key == 'recipient') { $recipient = $val; }
      elseif ($key == 'subject') { $subject = $val; }
      else {
         if ($key != 'realname' && $key != 'email') {
            $body .= "\n".str_replace('req_', '', $key).": $val";
         }
      }
   }
   $body .= "\n\n-------- Submission Details --------\n";
   $body .= "Remote Address: ".getenv('REMOTE_ADDR')."\n";
   $body .= "HTTP User Agent: ".getenv('HTTP_USER_AGENT')."\n\n";
   $body .= "--------------------------------------------------\n";
   $body .= "Powered by EZ FormMail. Available at http://www.sensationdesigns.com!";
   
   $mailheaders = "From: ".$_POST['realname']." <".$_POST['email'].">\n";
   $mailheaders .= "Reply-To: ".$_POST['email'];
   
   mail($recipient, $subject, $body, $mailheaders);
   header("Location: $success_url");
}
else {
   echo '<center>You have access this page from an invalid location. Please click <a href="'.$siteurl.'">here</a> to go to '.$siteurl.'.</center>';
}

Print_Footer();
?>


How to Install:
1) Unzip the files into a folder
2) Open ez_formmail.php with any standard text editor and configure the variables (at the top of script). Each variable has a short description as to what it is for.
3) Upload ez_formmail.php to your website. You do not need to change the file permissions or anything.

How to Use:
On your feedback/contact form, have the action attribute in the form tag point to the script.
Example: <form action="ezformmail.php" method="post">

You must have 2 fields in your form, and those are realname and email. These are required and the script will not function without them.
Example:
Name: <input type="text" name="realname"><BR>
E-mail address: <input type="text" name="email">

You can also have any field be required, so that a value must be entered. To do this, simply add req_ in front of the name.
Example: Address: <input type="text" name="req_address">

Hope that helps :)

WhiteDevil
_________________
Back to top View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
shanman
-


Joined: 14 Apr 2003
Posts: 5

PostPosted: Mon Apr 14, 2003 3:55 pm    Post subject: Reply with quote

OK might not have explained myself very well.

Here is the script again - not sure if its the same as above cos ive made recent changes!

<?php
$msg = "TD Name:\t$name\n";
$msg .= "Tournament ID:\t$tid\n";
$msg .= "Disqualified Players ID:\t$pid\n";
$msg .= "Disqualified Players Username:\t$pname\n";
$msg .= "Reason for disqualification:\t$reason\n";
$msg .= "Round disqualified in:\t$round\n";
$msg .= "Bananabux to be debited:\t$todebit\n";
$recipient = "$email";
$subject = "Sub Report";
$mailheaders = "From: Goddess Pond <> \n";
mail($recipient, $subject, $msg, $mailheaders);
?>


What I want to know is there a way to send theis email to say my email addy as well as urs when u click the button?

Many thanks


Last edited by shanman on Mon Apr 28, 2003 3:09 pm; edited 1 time in total
Back to top View user's profile Send private message
vbgunz
-


Joined: 02 Feb 2003
Posts: 615
Location: Florida

PostPosted: Mon Apr 14, 2003 9:14 pm    Post subject: Reply with quote

Are you trying to send a confirmation to the sbumitter of the form or are you trying to email two other individual addresses *other* than a confirmation to the user submitting the form?

User A submits the form and the form emails Users B and C... Is this what you're trying to accomplish or User A submits the form and the form emails Users A and B?
_________________
Victor B. Gonzalez
http://aeonserv.com
Back to top View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
shanman
-


Joined: 14 Apr 2003
Posts: 5

PostPosted: Mon Apr 14, 2003 10:04 pm    Post subject: Reply with quote

I'm trying to get user A to submit the form and it is sent to user B and C.

My manager and line manager both need a copy of the same report.
Back to top View user's profile Send private message
shanman
-


Joined: 14 Apr 2003
Posts: 5

PostPosted: Wed Apr 23, 2003 9:30 am    Post subject: Reply with quote

OK I'm sure someone reading this must know!!

If not does anyone know where I may be able to get help on this topic.

Many thanks
Back to top View user's profile Send private message
vbgunz
-


Joined: 02 Feb 2003
Posts: 615
Location: Florida

PostPosted: Wed Apr 23, 2003 10:05 am    Post subject: Reply with quote

I only wanted to clarify your question for others as I personally do not know how to do it. I am certain it could be done but it is not a trick easily found... You'll have to do some searching and maybe elsewhere... I needed such a script once but it proved so hard to find... To date, I do not have any resources on it, sorry. Good luck with your quest and please post back when you have found it, thanks and good luck :)
_________________
Victor B. Gonzalez
http://aeonserv.com
Back to top View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
shanman
-


Joined: 14 Apr 2003
Posts: 5

PostPosted: Mon Apr 28, 2003 3:05 pm    Post subject: Reply with quote

Thx for your help vb. I think I've found the solution now but need to test it.
Back to top View user's profile Send private message
TheLinker
-


Joined: 05 Apr 2002
Posts: 165
Location: Oslo, Norway

PostPosted: Mon Apr 28, 2003 5:16 pm    Post subject: Reply with quote

http://www.php.net/manual/en/function.mail.php explains how to send to multiple recipients.
Back to top View user's profile Send private message Visit poster's website
vbgunz
-


Joined: 02 Feb 2003
Posts: 615
Location: Florida

PostPosted: Mon Apr 28, 2003 6:42 pm    Post subject: Reply with quote

Thanks Shan and Linker... Good to know resources are sprouting up :)
_________________
Victor B. Gonzalez
http://aeonserv.com
Back to top View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group