WEB php mail form error

Discussion in 'OT Technology' started by AnoesisX, Jul 9, 2008.

  1. AnoesisX

    AnoesisX New Member

    Joined:
    Feb 19, 2005
    Messages:
    2,868
    Likes Received:
    0
    Location:
    Boca Rotten, Florida
    I have an email form on the contact page of a website. when i click submit i get :
    The server encountered an unexpected condition which prevented it from fulfilling the request.
    The script had an error or it did not produce any output. If there was an error, you should be able to see it in the error log.


    I used the same php script as i did on another site i did and it works fine all i did with this one is change the email in the php script which is this:
    Code:
    <?php
    
    foreach($_POST as $key=>$value) {
                    
        $emailBody .= "$key: " . trim(stripslashes($value)) . "\n";
    
    }
    
    $to = [email protected]';
    $subject = 'INQUIRY';
    
    $success = mail($to, $subject, $emailBody);
    
    // redirect to success page 
    
    if ($success){
    
      print "<meta http-equiv=\"refresh\" content=\"0;URL=index.html\">";
    
    }
    
    else{
    
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
    
    }
    
    
    ?>
    html code for the form
    Code:
    <div class="style2" id="form1"> <form id="form1" method="post" action="contact.php">
                <p>Name:<br />
                <input type="text" name="Name" />
    
                </p>
                <p>Email-Adress:<br />
                <input type="text" name="Email" />
                </p>
                <p>Phone:<br />
                <input type="text" name="Phone" />
                </p>
                <p>Message:<br />
    
                <textarea name="Message" cols="25" rows="4"></textarea>
                </p>
                <p>
                  <input type="submit" name="submit" value="Submit" />
                </p>
                 </form>
    
    </div>
     
  2. intrktevo

    intrktevo New Member

    Joined:
    Oct 18, 2004
    Messages:
    5,781
    Likes Received:
    0
    Location:
    UCF
    try initializing the $emailBody variable before using it in the foreach loop.

    $emailBody = '';

    Also, check to make sure that the mail funtion is even available at your new host.
     
  3. EkriirkE

    EkriirkE Zika Xenu OT Supporter

    Joined:
    Jan 11, 2004
    Messages:
    14,799
    Likes Received:
    0
    Location:
    Dublin & San Francisco, CA
    The above is a good start,
    do you have access to the php error log?
     
  4. noon

    noon get high and teach me how to listen

    Joined:
    May 4, 2002
    Messages:
    3,384
    Likes Received:
    0
    Location:
    Lawrence, KS
    try this

    Code:
    <?php
    
    $emailBody = array();
    $to = [email protected]';
    $from = [email protected]';
    $subject = 'INQUIRY';
    
    $emailBody[] = 'Name: ' . isset($_POST['Name'])? trim(stripslashes($_POST['Name'])):'';
    $emailBody[] = 'Email: ' . isset($_POST['Email'])? trim(stripslashes($_POST['Email'])) : '';
    $emailBody[] = 'Phone: ' . isset($_POST['Phone'])? trim(stripslashes($_POST['Phone'])) : '';
    $emailBody[] = 'Message: '; 
    $emailBody[] = isset($_POST['Message'])? trim(stripslashes($_POST['Message'])) : '';
    
    $emailBody = implode("\n", $emailBody);
    
    if (mail($to, $subject, $emailBody, "From: {$from}\r\nReply-To: {$from}\r\n"))
     @header('Location: index.html');
    else
     @header('Location: error.html');
    
    exit;
    
    ?>
     
    Last edited: Jul 9, 2008
  5. AnoesisX

    AnoesisX New Member

    Joined:
    Feb 19, 2005
    Messages:
    2,868
    Likes Received:
    0
    Location:
    Boca Rotten, Florida
    its the same hosting company
     
    Last edited: Jul 9, 2008
  6. AnoesisX

    AnoesisX New Member

    Joined:
    Feb 19, 2005
    Messages:
    2,868
    Likes Received:
    0
    Location:
    Boca Rotten, Florida
    same problem
     
  7. noon

    noon get high and teach me how to listen

    Joined:
    May 4, 2002
    Messages:
    3,384
    Likes Received:
    0
    Location:
    Lawrence, KS
    mail server problem, you could try SOAP email
     

Share This Page