Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 19

Thread: PHP Email form

  1. #1
    New Coder
    Join Date
    Mar 2005
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP Email form

    Howdy...
    Basically i have a form at www.loddonexplorers.co.uk/contact.php ... i know it dosent look good because i worry about cosmetics after it works! I would like a PHP email form basically.. BUT.. i want it to be able to email two address... So when i select Webmaster it emails webmaster@loddonexplorers.co.uk when you click submit, or when you select enquiries it emails enquiries@loddonexplorers.co.uk

    Any help would be appreciated! Cheers
    Scott

  • #2
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    hi

    use following:

    if (_Post[Contact] == "webmaster" ) {

    $toemail = "webmaster@loddonexplorers.co.uk";

    } else {

    $toemail = "enquiries@loddonexplorers.co.uk";
    }

    rest U know. I hope so.

    akash sinha
    websoftexpert@yahoo.com
    http://www.akash.biz

  • #3
    New Coder
    Join Date
    Mar 2005
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well as i dnt know lol can someone else help me out? Cheers for that tho buddy

  • #4
    Regular Coder
    Join Date
    Dec 2002
    Location
    UK
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts
    When you say "select" are we talking radio buttons?

    If so, you will have 2 of them like so..

    Code:
    <input type="radio" name="toemail" value="webmaster@loddonexplorers.co.uk" />
    <input type="radio" name="toemail" value="enquiries@loddonexplorers.co.uk" />
    That way, when the form is submitted, the variable $_POST['toemail'] (assuming your posting and not getting) will either be webmaster@loddonexplorers.co.uk or enquiries@loddonexplorers.co.uk

    And your php would be like...

    PHP Code:
    // if user clicks send
    if($_POST['submit']=="Send") {
    // send the email here, using $toemail to specify where to send.

    Hope this helps.

  • #5
    Senior Coder JamieR's Avatar
    Join Date
    Oct 2004
    Location
    United Kingdom
    Posts
    3,161
    Thanks
    0
    Thanked 5 Times in 5 Posts
    it's probably full of bugs (haha) but I think I've got the general idea of whatcha after:
    PHP Code:
    <?php

    $name 
    $_POST['name'];
    $message $_POST['message'];
    $email $_POST['email'];

    if (
    $_POST['contact'] == 'webmaster')
    {
    $email_to '"Webmaster" <webmaster@londonexplorers.co.uk>';
    }else{
    $email_to '"Enquiries" <enquries@londonexplorers.co.uk>';
    }

    mail($email_to$name$message$email);

    exit()
    ?>
    Edit: corrected code error
    Last edited by JamieR; 09-13-2005 at 11:13 PM. Reason: corrected php error

  • #6
    New Coder
    Join Date
    Mar 2005
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Lol hi again.. any idea how to fix the error on the website?

    http://www.loddonexplorers.co.uk/form_mailer.php

    the script is exactly the same as weazels

  • #7
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    A slight error in weazels code:

    change:

    PHP Code:
    $name $_POST['name'];
    $message $_POST['message;];
    $email = $_POST['
    email]; 
    to:

    PHP Code:
    $name $_POST['name'];
    $message $_POST['message'];
    $email $_POST['email']; 

  • #8
    Senior Coder JamieR's Avatar
    Join Date
    Oct 2004
    Location
    United Kingdom
    Posts
    3,161
    Thanks
    0
    Thanked 5 Times in 5 Posts
    oops, - I wrote that quick

  • #9
    New Coder
    Join Date
    Mar 2005
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts
    lol thanks.. um another error... Parse error on line 2

    PHP Code:
    <?php 

    $name
    *=*$_POST['name']; 
    $message*=*$_POST['message']; 
    $email*=*$_POST['email'];* 
     
    if (
    $_POST['contact'] == 'webmaster'

    $email_to '"Webmaster" <webmaster@londonexplorers.co.uk>'
    }else{ 
    $email_to '"Enquiries" <enquries@londonexplorers.co.uk>'


    mail($email_to$name$message$email,); 

    exit 
    ?>
    again avaliable to see at the website mentioned above

  • #10
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry, I missed another error in the original code (sorry weazel, but that wasnt your day )

    change this section here, adding a curly brace below the if($_POST.....) bit.
    PHP Code:
    if ($_POST['contact'] == 'webmaster'
    {
    $email_to '"Webmaster" <webmaster@londonexplorers.co.uk>'
    }else{ 
    $email_to '"Enquiries" <enquries@londonexplorers.co.uk>'


  • #11
    New Coder
    Join Date
    Mar 2005
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the help... still getting the parse error on line 2 (see above)

    Fet

  • #12
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, there are some asterisks *, in there:

    PHP Code:
    $name*=*$_POST['name']; 
    $message*=*$_POST['message']; 
    $email*=*$_POST['email'];* 
    I dont know how they got there though, they shouldnt be in there.

  • #13
    Senior Coder JamieR's Avatar
    Join Date
    Oct 2004
    Location
    United Kingdom
    Posts
    3,161
    Thanks
    0
    Thanked 5 Times in 5 Posts
    ah well....^%$" happens

  • #14
    New Coder
    Join Date
    Mar 2005
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the astrix dont appear on my version.. heres my current version..

    PHP Code:
    <?php 

    $name
    *=*$_POST['name']; 
    $message*=*$_POST['message']; 
    $email*=*$_POST['email']; 

    if*(
    $_POST['contact']*==*'webmaster'
    {
    $email_to*=*'"Webmaster" <webmaster@londonexplorers.co.uk>'
    }else{ 
    $email_to*=*'"Enquiries" <enquries@londonexplorers.co.uk>'


    mail($email_to,*$name,*$message,*$email,); 

    exit() 
    ?>
    Still getting a parse error.. if we cant fix this anyone know of another script?

    EDIT : OK.. I dont know why they the astrix appear.. they arnt on my clipboard!
    Last edited by digisoft; 09-13-2005 at 07:32 PM.

  • #15
    Senior Coder JamieR's Avatar
    Join Date
    Oct 2004
    Location
    United Kingdom
    Posts
    3,161
    Thanks
    0
    Thanked 5 Times in 5 Posts
    remove the last , from the mail function -

    instead of
    PHP Code:
    mail($email_to$name$message$email,); 
    PHP Code:
    mail($email_to$name$message$email); 
    I don't know why the hell them asterisks are appearing tho.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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