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 6 of 6
  1. #1
    New Coder
    Join Date
    Nov 2011
    Location
    England
    Posts
    64
    Thanks
    10
    Thanked 3 Times in 3 Posts

    Trouble with contact Form

    Hey Guys,

    I've recently started learning PHP and am trying to code a simple contact form, the form looks right and acts how it is suppose to when you press submit however the information does not actually get sent.

    Here's the php code

    PHP Code:

    <?php

        $recieverEmail 
    'adam.cullen@live.co.uk';
        
    $resultError 'Sending Failed! Please fill in all forms!';
        
    $resultSuccess 'We have recieved your message, Thank You.';
        
        
    $emailSubject 'Message from Contact Form on Dot 2 Dot Website: ' .$subject;
        
    $subject $_POST["subject"];
        
    $email $_POST["email"];
        
    $message $_POST["message"];
        
    $name $_POST["name"];
        
    $phone $_POST["name"];
        
        
    $mailHeader "From: " $email "\r\n";
        
    $mailHeader .= "Reply-To: " $email "\r\n";
        
    $mailHeader .= "Content-type: text/html; charset=iso-8859-1\r\n";
        
        
    $messageBody "Message: <br/>" nl2br($message) . "<br/>";
        
    $messageBody .= "Name: " $name "<br/>";
        
    $messageBody .= "Email: " $email "<br>";
        
    $messageBody .= "Phone: " $phone;
        
        if( empty(
    $subject) or empty($email) or empty($name) or empty($message) or empty($phone) ){
            
    header('Location: index.php?result=' $resultError );
        } else {
            
    mail($recieverEmail$emailSubject$messageBody$mailHeader);
            
    header('Location: index.php?result=' $resultSuccess );
        }



    ?>

    sorry if it's something simple
    Absolutely amazing use of HTML5
    Check it out in Google Chrome www.thewildernessdowntown.com/
    Thanks for all the help i've recieved on this Forum

  • #2
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,301
    Thanks
    10
    Thanked 283 Times in 282 Posts
    You should check the return status of the mail() function. It may be telling you something that you're ignoring.

    Dave

  • #3
    New Coder
    Join Date
    Nov 2011
    Location
    England
    Posts
    64
    Thanks
    10
    Thanked 3 Times in 3 Posts
    Sorry for my ingnorance but how do i do that??
    Absolutely amazing use of HTML5
    Check it out in Google Chrome www.thewildernessdowntown.com/
    Thanks for all the help i've recieved on this Forum

  • #4
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,301
    Thanks
    10
    Thanked 283 Times in 282 Posts
    PHP Code:
    if (!mail($recieverEmail$emailSubject$messageBody$mailHeader))
    echo 
    "mail failed to send"
    Dave

  • #5
    New Coder
    Join Date
    Nov 2011
    Location
    England
    Posts
    64
    Thanks
    10
    Thanked 3 Times in 3 Posts
    Sorry but i don't understand what that does as all seems to do is add in the line "mail failed to send" into the form page.
    Absolutely amazing use of HTML5
    Check it out in Google Chrome www.thewildernessdowntown.com/
    Thanks for all the help i've recieved on this Forum

  • #6
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,301
    Thanks
    10
    Thanked 283 Times in 282 Posts
    Ok, so that's telling you the mail function is unable to work (as opposed to it sending the mail, but it not getting there). I'd print out the values of the four parameters you're passing to mail(), and see if they contain what you expect.

    Dave


  •  

    Posting Permissions

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