PHP Contact Form

Discussion in 'Web Design and Development' started by GottaQ, May 30, 2010.

  1. GottaQ macrumors newbie

    Joined:
    Feb 13, 2010
    #1
    I have created a contact form on my website which allows input for "Name", "Email" and "Comments". I have also created a 'thank you' page which confirms the message has been sent, and a link to return to the homepage.

    The problem: When I insert data into the text fields and click "send" it takes me to a blank* page, rather than the "thank you" page. However, when I leave the fields blank and click send, it navigates to the "thank you" page successfully.

    Anyone familiar with this when using PHP mail forms?
     
  2. citizenzen Suspended

    Joined:
    Mar 22, 2010
    #2
    You know what they always say...

    You gotta post the code before we can tell what's really going on.
     
  3. Truffy macrumors 6502a

    Truffy

    Joined:
    May 9, 2005
    Location:
    somewhere outside your window...
    #3
    At a wild guess, I'd say that your script is screwed in data handling and the blank page simply represents a stop in the script producing the acknowledgement page. Ideally, your script should check for blank entries and not allow the visitor to proceed.

    But, yeah, what citizenzen said.
     
  4. GottaQ thread starter macrumors newbie

    Joined:
    Feb 13, 2010
  5. GottaQ thread starter macrumors newbie

    Joined:
    Feb 13, 2010
    #5
    Found the problem. It was a mistake on my part. Thanks for the help fellas.
     
  6. 7on macrumors 601

    7on

    Joined:
    Nov 9, 2003
    Location:
    Dress Rosa
    #6
    Here what I use.
    PHP:
    <? if ($_POST['submit']) {        
    $name     $_POST['name'];
    $phone    $_POST['phone'];
    $email    $_POST['email'];
    $type     $_POST['type'];
    $comments $_POST['comments'];
    $deny $_POST['deny'];
    $goodform true;

    if(
    $deny) {exit;}
    if(!
    $email && !$phone) {$message '<p>Please enter your Email or Phone Number.</p>'$goodform false;}

    $body =<<< EOF
    Contact Submission
    ----------------------------------------------
    Name: 
    {$name}
    Phone: 
    {$phone}
    Email: 
    {$email}

    Type: 
    {$type}

    Questions / Comments
    --------------------
    {$comments}
    EOF;

        if (
    $email) {$mailheaders  'From: '$email "\r\n";} else {$mailheaders  'From: form@email.com' "\r\n";}
        
    $mailheaders .= 'Bcc: email@email.com'."\r\n";
        
    $subject 'Fullfillment Contact Form';
        
    $emails = array('email@email.com.com');
        
        foreach (
    $emails as $email) {
            if(
    $goodform) {
                
    mail($email$subject$body$mailheaders);
                
    $message '<p>Thank you for your submission! We will repsond to your inquiry as soon as possible.</p>';
            }
        }
    }
    ?>

     

Share This Page