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.
Results 1 to 5 of 5

Thread: mail() error

  1. #1
    New Coder
    Join Date
    Aug 2006
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    mail() error

    I am using this coe and it keeps giving me the error that I have got 6 parameters when only 5 are allowed.
    PHP Code:
    <?php

      $name 
    $_REQUEST['name'];
      
    $email $_REQUEST['email'];
      
    $message $_REQUEST['message'];
      
      
    mail"contac@web.com""web.com Contact Us",
        
    $name$email$message"From: $email" );
      
    header"Location: ../thanks.htm" );

    ?>
    I know I could get rid o the $email parameter, but I need that there becase the From:$email does not work it just says the email comes from webmaster@....

    Can anyone tell me how to get round the error?
    Thanks

  • #2
    New Coder
    Join Date
    Aug 2006
    Location
    Netherlands
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can only have 5 (maximum, not required) parameters in your MAIL() function. PHP manual:
    bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]] )
    I guess the first 2 are to be taken out.

    Ronald
    RTFM is an almost extinct art form, it should be subsidized.

  • #3
    Registered User
    Join Date
    Oct 2004
    Posts
    592
    Thanks
    0
    Thanked 1 Time in 1 Post
    Hope this help.

    I rewrote like :
    PHP Code:

    $name 
    = (isset($_REQUEST['name']))?$_REQUEST['name']):exit;
    $email = (isset($_REQUEST['email']))?$_REQUEST['email']:exit;
    $message = ((isset($_REQUEST['message'])?$_REQUEST['message']:exit;

    $body "$name wrote :<br /><br />".$message;

    $headers "From:$email\n\r"// this is who submit contact form to you
    $headers .= "Content-Type:text/html\n\r";  // output html

    // use @ sign to prevent php from outputing errors to users
    // mail() return 1 if successful and 0 if not 
    // if mail() will ensure users knowing if mailing is actually  successful or not

    if (@mail("yourmail@domain.com","Users Contact",$body,$headers)) {
           
    header"Location: ../thanks.htm" ); 
     }else {
           echo 
    "Our mail server is currently being maintained.<br />Please try again later.<br />Thank you.";
     } 
    This is basic.

    For intermediate,you must use session cookie sending time or cacha image to prevent spamming. And also use regular expression to prevent submitting of bad mail.
    Last edited by iota; 08-28-2006 at 01:38 PM.

  • #4
    New Coder
    Join Date
    Aug 2006
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's great, thanks very much. Luckily I only need basic as I only have a small site, not many people to spam me.

  • #5
    Regular Coder
    Join Date
    Dec 2004
    Location
    Manchester, UK
    Posts
    134
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by manicman
    That's great, thanks very much. Luckily I only need basic as I only have a small site, not many people to spam me.
    Ah OK. Yeah I forgot that small sites needn't worry about spam. Spammers only target big sites.


  •  

    Posting Permissions

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