Jump to content

[SOLVED] php form Enquiry for: Array.. dont want Array


foevah

Recommended Posts

Ok when I submit this contact form this is what the subject says: Enquiry for: Array

What I want the subject to say is: Enquiry for: test1

 

I used to have switch ($_POST but this put the email in the subject and not the value

 

This is the code:

 

$recipients = array(

'recipient_1' => 'test1@example.com',
'recipient_2' => 'test2@example.com',
'recipient_3' => 'test3@example.com'

);

$my_email = $recipients[$_REQUEST['recipient']];

$subject = 'Enquiry for: '. $recipients . "\r\n";
$message = 'From: '. $email . "\r\n" .
$headers = 'From: Site contact form - '. $recipients . "\r\n" . 
    		'Reply-To: '. $email . "\r\n" .
    		'X-Mailer: PHP/' . phpversion();
   
	if(mail($my_email, $subject, $message, $headers)){
		echo "<br /><span style='font-weight:bold;color:#51236D'>Thank you for your enquiry, \nwe will review it and contact you as soon as possible.</span><br /><br />";
	}
   } 
}

 

Form:

<select name="recipient" id="recipient" style="width:360px">
   <option value="sales">Sales, Marketing & Media</option>
<option value="recipient_1">test1</option>
<option value="recipient_2">test2</option>
<option value="recipient_3">test3</option>
   </select>

Link to comment
Share on other sites

$recipients is an array.

 

$subject = 'Enquiry for: '. $recipients . "\r\n";

 

thers your error.

 

$headers = 'From: Site contact form - '. $recipients . "\r\n" .

 

theres another.

 

'Reply-To: '. $email . "\r\n" .

 

Where is $email defined?

Link to comment
Share on other sites

email is in the form:

<label for="email">Email</label>

<input name="email" id="email" style="width:360px" value="<?php echo $_POST['email']; ?>" />

 

samshel -

your solution while only show sales in the subject.. if the user selects test2 from the drop down then i want test2 to be in the subject

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.