1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Please help with my contact form. Mail() expects at most 5 parameters...

Discussion in 'HTML & Website Design' started by jimsmith, Jul 17, 2007.

  1. #1
    I am trying to code a contact form with 6 text boxes (name, email, what picture they want to buy, etc.) but I keep getting this error.

    Warning: mail() expects at most 5 parameters, 7 given in /*sendmail.php on line 12
    Code (markup):
    Here is my sendmail.php text

    <?
      $email = $_REQUEST['email'] ;
      $name = $_REQUEST['name'] ;
      $print = $_REQUEST['print'] ;
    $size = $_REQUEST['size'] ;
    $number = $_REQUEST['number'] ;
    
      mail( "*@gmail.com", "Lindsay Test",
         $name, $print, $size, $number, "From: $email" );
      header( "Location: http://www.google.com" );
    ?>
    Code (markup):
    Any ideas? I'm desperate. Thanks guys.
     
    jimsmith, Jul 17, 2007 IP
  2. rgchris

    rgchris Peon

    Messages:
    187
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    As the error says, you're sending too many params to the function. Looks like a fair bit of them can be put in the actual mail message.
     
    rgchris, Jul 17, 2007 IP
  3. chopsticks

    chopsticks Active Member

    Messages:
    565
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #3
    chopsticks, Jul 17, 2007 IP
  4. mikemotorcade

    mikemotorcade Peon

    Messages:
    645
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You need to make sure your syntax is right. you can't pass a parameter to the mail function called size, for instance. This is the syntax you need to follow:
    mail( $to, $subject, $message, $additional_headers, $additional_parameters );
    PHP:
    you should do something like this:
    //create the message you want to send first
    $message = "You recieved an email!!";
    $message = "Name: " . $name . "\n";
    $message .= "Print: " . $print . "\n";
    $message .= "Size: " . $size . "\n";
    $message .= "Number: " . $number . "\n";
    
    //then pass that variable into the function
    mail( "*@gmail.com", "Lindsay Test", $message, "From: $email" );
    PHP:
    Also, I don't know what you are trying to do with the "*@gmail.com" line. That parameter is where you would put where you want to send it. I don't think you would want to send it to everyone who has a gmail account. I don't even think that would work. I don't know how php would handle that kind of thing.


    Check out http://us2.php.net/function.mail for info on the mail function.
     
    mikemotorcade, Jul 17, 2007 IP
  5. jimsmith

    jimsmith Peon

    Messages:
    629
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thanks guys for all your help, here's the code I wound up using in case it can help anyone else

    <?php
      $email = $_REQUEST['email'] ;
      $message = $_REQUEST['message'] ;
        $name = $_REQUEST['name'] ;
      $print = $_REQUEST['print'] ;
        $size = $_REQUEST['size'] ;
      $number = $_REQUEST['number'] ;
      
    $totalmessage = "
    		Name:		$name  \n
    		Print:		$print  \n
    		Size:		$size  \n
    		Number:		$number \n
    		Message:	$message \n";
    	
    //then pass that variable into the function
    mail( "*@gmail.com", "Lindsay Test", $totalmessage, "From: $email" );
    ?>
    Code (markup):
     
    jimsmith, Jul 19, 2007 IP
  6. mikemotorcade

    mikemotorcade Peon

    Messages:
    645
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I'm still confused as to what the "*@gmail.com" address is for. What exactly are you doing here?
     
    mikemotorcade, Jul 19, 2007 IP
  7. jimsmith

    jimsmith Peon

    Messages:
    629
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #7
    mike, the star is so i don't have to post my real email address here
     
    jimsmith, Jul 19, 2007 IP
  8. mikemotorcade

    mikemotorcade Peon

    Messages:
    645
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    0
    #8
    oh..

    Duh, I'm a retard.
     
    mikemotorcade, Jul 19, 2007 IP
  9. suyog3p

    suyog3p Guest

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    jimsmith, thnks i solved problem


     
    suyog3p, Apr 8, 2011 IP
  10. kvwest125

    kvwest125 Peon

    Messages:
    321
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #10
    kvwest125, Apr 9, 2011 IP
  11. @Fitz

    @Fitz Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Thanks for the info it was very helpful! However, I am wondering (using the example above) If someone does not fill in the size in the form, is there a way to comment out the line in the sendmail form?

    So if $size =(empty) than this line would not be in the email. Size: $size \n
     
    @Fitz, Sep 28, 2011 IP