Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 3 of 3

Thread: Send to one email address or another

  1. #1

    Send to one email address or another

    Been playing around with an email contact form with PHP so that the user can select which place they want their enquiry to go to, depending on which radio box they check.

    It seems to send to the second address, but not the first.

    "sendto" is the name of the radio boxes.

    I think I have it working through using 'switch', however I want to know why this way didn't work.

    Can anyone shed some light on this for me?

    Code:
    <?php
    
        $sendto = $_POST['sendto'];
        $subject = "Enquiry";
        $name = $_POST['name'];
        $phone = $_POST['phone'];
        $email = $_POST['email'];
        $message = $_POST['message'];
        
        if($sento == "value1") {
        
        $to = "value1email@whatever.com";
        $body = "Name: $name\nPhone: $phone\nEmail: $email\nMessage: $message\n";
        
        echo "Thank you. Your enquiry has been submitted to location 1.";
        mail($to, $subject, $body);
        
        } 
        
        elseif($sendto == "value2") {
        
        $to = "value2email@whatever.com";
        $body = "Name: $name\nPhone: $phone\nEmail: $email\nMessage: $message\n";
        
        echo "Thank you. Your enquiry has been submitted to location 2.";
        mail($to, $subject, $body);
        
        }
        
        else{
        echo "An error has occured. Please try again later.";
        }
    ?>

  2. #2
    if($sento == "value1") {
    should be
    if($sendto == "value1") {

    typo

  3. #3
    Ah ha!

    Hahahaha, I knew it'd be something silly like that. I read over it a heap of times too, and just missed it. >_<

    Thanks!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012