forms - Email send to 2 different locations in php

801

So, if you fill out this contact form i've got. Then, you'll fill out your return email just like every contact form out there. This variable is set to

 $from=$_POST["email"];

So, I have a new feature in my contact form that enables users to send a copy of it to their email address that they submitted in the "email" section of the form. Except, I have this php code to take care of this for that user if they checked the box saying yes they wanted to...

if ($_POST['copy'] == "on") {
     $receiver = "my email addr" || $from;
 }

with the name "copy" being the checkbox, here is that code now...

<div class="6u 12u$(small)">
    <input type="checkbox" id="copy" name="copy">
    <label for="copy">Email me a copy of this message</label>
</div>

Now, idk if this is the problem, but when I submitted the form with "get" then checked the box for the copy then it came back in the url bar as "&copy=on".

793

Answer

Solution:

this is not valid

  $receiver = "my email addr" || $from;

to send to another address you append with a comma

  $receiver = "my email addr".','.$from;

then:

mail($receiver,$subject,$body);

People are also looking for solutions to the problem: php - How to update the multiselected checkbox values in laravel

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.