multiple website emails, one form for customers for all emai

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

bufhal wrote:yeah it looks red...........................
?

I wonder why?

Did you figure it out? ;)
bufhal
Forum Newbie
Posts: 19
Joined: Sat Apr 17, 2004 11:39 am

Post by bufhal »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Not yet...I am still getting parse error:
Parse error: parse error, unexpected T_IF in /home/attonet/www/atto.net/mail4.php on line 9

Not expert PHP coder and I am not sure of the double quotes....

Code: Select all

<?php
$emails = array(

"gz" => "gz@email.com.com",
"dd" => "dd@email.com",
"rpec" => "rpec@email.com",
"mkt" => "mkt@email.com",
)
if (!empty($_GET["email_to"]) && in_array($_GET["email_to"], $emails)) { 

   if (mail(  )) { 
      echo "Email sent"; 
      exit(); 
   } 
}
?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Hint: You're missing a semi-colon somewhere.
bufhal
Forum Newbie
Posts: 19
Joined: Sat Apr 17, 2004 11:39 am

thanks

Post by bufhal »

all set...thanks
bufhal
Forum Newbie
Posts: 19
Joined: Sat Apr 17, 2004 11:39 am

Still not worting, can you take a look?

Post by bufhal »

I am sorry, upon further testing I was wrong. This is not working correctly. Can you please take a look and see why the "thank you" page code will not grab the array email specified on the first page. I think I need to include the value of the email address which is derived from the array in mail4.php as a hidden value, use session variables. Please let me know. I appreciate your help. Thank you again in advance.
Since this is three pages of code and I keep getting messages from the moderator, I have decided to bold the sections to help understand what goes where rather than breaking up the code.

The page with the email gif link is first:
E-mail: <a href="mail4.php?email_to=mkt"><img src="images/Ed_email.gif" width="152" height="14" border="0">[/url]

That email link should grab the correct email address from the array on "mail4.php"below:

Code: Select all

<?php
$emails = array(
'mkt' => 'mkt@tech.com',
'dd' => 'dd@email.com',
'rpec' => 'gz@tech.com',
'gz' => 'mkt22@tech.com'
);
if (!empty($_GET['email_to']) && in_array($_GET['email_to'], $emails)) {

   if (mail(  )) { 
      echo 'Email sent'; 
      exit(); 
   } 
}
?>


Code: Select all

<form action="mail2.php" method="POST"> 
   <p><b>Subject</b><br> 
   <input type="text" name="subject" size=50> 
   <br><br> 
   
<b>Message</b><br> 
<textarea cols=40 rows=10 name="message"></textarea><br><br>
<input type="submit" value=" Send "> 
</form>
The "thank you" page, "mail2.php" below that actually sends the email is not grabbing the email address from the array. I left the comments in

Code: Select all

<?php
/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$email = $HTTP_POST_VARS['email'];
$subject = $HTTP_POST_VARS['subject'];
$message = $HTTP_POST_VARS['message'];

/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if ($subject == "") {
  echo "<h4>No subject</h4>";
  echo "<a href='javascript:history.back(1);'>Back</a>";
}

/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
 elseif (mail($emails,$subject,$message)) {

echo "<h3>Thank you for sending email</h3>";
} else {
  echo "<h4>Can't send email to $email</h4>";
}
?>
Last edited by bufhal on Mon Oct 30, 2006 3:13 pm, edited 1 time in total.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Please can you click "Edit" on your post and wrap your PHP code inside

Code: Select all

 [/php ] tags so we can read it easier? :)

Example:

[syntax=php]Blah blah usual post nonsense explaining problem

[php]<?php

$your_php = "code here";

?>
Rest of post[/syntax]
Post Reply