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' => '[email protected]',
'recipient_2' => '[email protected]',
'recipient_3' => '[email protected]'

);

$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>

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.