php Form Error..

Discussion in 'PHP' started by PMedia, Feb 26, 2008.

  1. #1
    "Warning: mail() expects at most 5 parameters, 9 given in /home/username/public_html/process-form.php on line 23

    Warning: Cannot modify header information - headers already sent by (output started at /home/username/public_html/process-form.php:23) in /home/backstab/public_html/process-form.php on line 26"

    Not sure what im doing wrong..?

    Thanks.
     
    PMedia, Feb 26, 2008 IP
  2. shamess

    shamess Well-Known Member

    Messages:
    1,127
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    185
    #2
    Can you paste us the code that's on line 23, please?
     
    shamess, Feb 26, 2008 IP
  3. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #3
    Post the code for the mail section. Second part means you are trying to modify the headers for the webpage after you have already sent the headers. You can't modify the headers if you have started outputting the webpage. Once again, code helps. Just try to post the important parts. line 20- 26+.
     
    shallowink, Feb 26, 2008 IP
  4. shamess

    shamess Well-Known Member

    Messages:
    1,127
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    185
    #4
    Actually, the second error message is caused because the first error message is being output first. If we fix the mail() problem, the header problem will go away too, most likely.
     
    shamess, Feb 26, 2008 IP
  5. PMedia

    PMedia Peon

    Messages:
    270
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    <?php
    // Pick up the form data and assign it to variables
    $Firstname = $_POST['Firstname'];
    $Lastname = $_POST['Lastname'];
    $Email = $_POST['Email'];
    $Job = $_POST['Job'];
    $Details = $_POST['Details'];
    $Budget = $_POST['Budget'];
    $Domain = $_POST['Domain'];

    // Build the email (replace the address in the $to section with your own)
    $to = 'myemail@email.com';
    $subject = "Quote Request";
    $Firstname = "Firstname";
    $Lastname = "Lastname";
    $Email = "Email";
    $Job = "Job";
    $Details = "Details";
    $Budget = "Budget";
    $Domain = "Domain";

    // Send the mail using PHPs mail() function
    mail($to, $subject, $Firstname, $Lastname, $Email, $Job, $Details, $Budget, $Domain);

    // Redirect
    header("Location: success.html");
     
    PMedia, Feb 26, 2008 IP
  6. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #6
    You have to sandwich the rest of that into the message. Plus you didn't define the headers to be sent.

    Here's an example from w3schools:
    
    <?php
    
    $to = "someone@example.com";
    $subject = "Test mail";
    $message = "Hello! This is a simple email message.";
    $from = "someonelse@example.com";
    $headers = "From: $from";
    mail($to,$subject,$message,$headers);
    echo "Mail Sent.";
    
    ?>
    
    Code (markup):
    Adapting that to your code would require pushing the $firstname $lastname $job $domain to the $message variable.

    $message = $Firstname . $Lastname . $job . $domain;
    Then redirect to the success page but really should set it up so it checks for success or failure and reports accordingly.
     
    shallowink, Feb 26, 2008 IP
  7. jeff_oneil

    jeff_oneil Peon

    Messages:
    29
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    For the love of god please use $firstname instead of $Firstname.

    Never capitalize the first letter of a variable. Capital letters are to be used for classes.
     
    jeff_oneil, Feb 26, 2008 IP