foevah Posted July 15, 2008 Share Posted July 15, 2008 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> Link to comment https://forums.phpfreaks.com/topic/114824-solved-php-form-enquiry-for-array-dont-want-array/ Share on other sites More sharing options...
samshel Posted July 15, 2008 Share Posted July 15, 2008 change subject to following. $subject = 'Enquiry for: '. $_REQUEST['sales']. "\r\n"; Link to comment https://forums.phpfreaks.com/topic/114824-solved-php-form-enquiry-for-array-dont-want-array/#findComment-590402 Share on other sites More sharing options...
trq Posted July 15, 2008 Share Posted July 15, 2008 $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 https://forums.phpfreaks.com/topic/114824-solved-php-form-enquiry-for-array-dont-want-array/#findComment-590404 Share on other sites More sharing options...
foevah Posted July 15, 2008 Author Share Posted July 15, 2008 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 https://forums.phpfreaks.com/topic/114824-solved-php-form-enquiry-for-array-dont-want-array/#findComment-590427 Share on other sites More sharing options...
samshel Posted July 15, 2008 Share Posted July 15, 2008 oops..sorry thought sales was the name of the drop down, it is recipient. try $subject = 'Enquiry for: '. $_REQUEST['recipient']. "\r\n"; Link to comment https://forums.phpfreaks.com/topic/114824-solved-php-form-enquiry-for-array-dont-want-array/#findComment-590433 Share on other sites More sharing options...
foevah Posted July 15, 2008 Author Share Posted July 15, 2008 cool thanks samshel that did the trick! Link to comment https://forums.phpfreaks.com/topic/114824-solved-php-form-enquiry-for-array-dont-want-array/#findComment-590455 Share on other sites More sharing options...
samshel Posted July 15, 2008 Share Posted July 15, 2008 please mark as solved Link to comment https://forums.phpfreaks.com/topic/114824-solved-php-form-enquiry-for-array-dont-want-array/#findComment-590461 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.