The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Send me a copy – PHP form doesn’t send copy

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #29968

    So I’ve got the following form:

    Then, the following PHP to process the form:

    // Receiving variables
    @$from = addslashes($_POST['from']);
    @$to = addslashes($_POST['to']);
    @$subject = addslashes($_POST['subject']);
    @$message = addslashes($_POST['message']);
    @$sendcopy = addslashes($_POST['sendcopy']);

    //Sending Email to form owner
    # Email to Owner
    $headers = "From: $from";
    if ($sendcopy == "on") {
    mail($from, $subject, $message, $headers);
    mail($to, $subject, $message, $headers);
    header("Location: thanks.php");


    It sends the form to the "to" address, but when I have the checkbox checked, it doesn’t send a copy of the email to the "from" address. This is so simple… why isn’t it working?


    Hi, I haven’t used check boxes before so i might be wrong but check boxes pass their data to php in an array. So where you declare your variable to the post data it actually turns into an array with only one value (if the box was ticked, otherwise it will be empty).
    So when you test tp send the array, just check if the first value of the array is equal to on.

    if ($sendcopy[0] == "on") {

    You might even just be able to see if the variable exists as if they don’t check the box nothing should get passed through. So this might even work,

    if ($sendcopy) {

    Again, im still learning with php so someone else will have to check this but there is no harm in testing it out, please let us know if it does work.

    Also while im on it, i don’t think you need to use the strip slashes on the checkbox post as the user can’t alter the value.


    Ok… I think my code works because I just tried some different email addresses and it sends correctly, it’s just the emails aren’t being delivered to my domain email address.

    Is it possible that it ignores emails that are sent to and from the same address?

    Rob MacKay

    On the checkboxes – forms only send array’ed data if you tell them to… for example:

    <input type="checkbox" name="data[value1][checkbox]" value="1" />

    would output the value – in this case "1" if you did:

    $data = $_POST;

    echo $data[value1][checkbox];

    Other than that it would just be a normal value stored within the global post or get array.

    And the next part – if it works with another email address, are you SURE you have put the email address in right? Yea I know, sorry, but it’s normally the silly things that I miss… :)

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Back End’ is closed to new topics and replies.