Home » Linux OS and Software » How-To » Error 500 - Internal Server Error on Submit Button
Fri, 24 June 2011 12:58 Go to next message
Registered: March 2011
Messages: 16
Hello,

I've got a basic contact form running, and when the user presses the Submit button, the browser displays Error 500 - Internal Server Error.

I've tried to review the error logs, but nothing seems to be logged. I've tried changing the permissions to my php file from 644 to 755, but that results in a "dead" submit button. I don't get an error, nor do I get my "thanks" page. An email is never sent.

My contact page is located here: http://www.mindypostoff.com/contact.html

My php code for Send_Form_Email.php is as follows:

<?php
if(isset($_POST['email'])) {

// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "mindy@ruralsquirrel.ca";
$email_subject = "Mindy Postoff - Website Contact Form";


function died($error) {
// your error code can go here
echo "I'm very sorry, but there were error(s) found with the form your submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}

// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['comments'])) {
died('I am sorry, but there appears to be a problem with the form your submitted.');
}

$first_name = $_POST['first_name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['telephone']; // not required
$comments = $_POST['comments']; // required

$error_message = "";
$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
if(!eregi($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "^[a-z .'-]+$";
if(!eregi($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
$string_exp = "^[0-9 .-]+$";
if(!eregi($string_exp,$telephone)) {
$error_message .= 'The Telphone Number you entered does not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";

function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}

$email_message .= "Name: ".clean_string($first_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Telephone: ".clean_string($telephone)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";


// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>

<!-- The rest of my html Thanks page continues... -->

Any help would be greatly appreciated!
Thanks,
Mindy : )
Fri, 24 June 2011 22:04 Go to previous messageGo to next message
Registered: January 2009
Messages: 62
I sent a test message and did not get a 500 error.

The output was totally blank. No source at all.

Later,
Chris
Fri, 24 June 2011 23:38 Go to previous messageGo to next message
Registered: March 2011
Messages: 16
Hey Chris,

Thanks for trying it out. Any ideas as to what's causing the blank output? I tried checking it again on my end and after repeatedly pushing the submit button, the Error 500 came up, after a number of apparent "dead" clicks.

I'm really stuck as to what the problem might be.

Thanks so much,
Mindy : )
Sat, 25 June 2011 18:32 Go to previous messageGo to next message
Registered: January 2009
Messages: 62
Hiya,

I'm sorry I missed it the first time around but check this out...

@mail($email_to, $email_subject, $email_message, $headers);

Remove the "@" and try again.

The usage of the "@" is unknown to me, but then again my php-fu is not what it once was.

Let me know how it goes.
Sun, 26 June 2011 14:43 Go to previous messageGo to next message
Registered: March 2011
Messages: 16
Hi Xenolith,

I'm not a PHP developer by any stretch of the imagination! I'm reusing code a friend gave to me from her website for the contact form. I've plugged the code into two other sites I've created and it's worked fine. Those other two sites, however, are currently hosted by Netfirms and Dotster on their servers.

Do you think that there's something wrong with the way I've got my VPS set up that's causing the issue?

Thanks!
Mindy : )
Sun, 26 June 2011 22:07 Go to previous messageGo to next message
Registered: January 2009
Messages: 62
Mindy,

If you can, please confirm that the "@" exists on the sites that work.

I have been unable to find that usage of the mail() command anywhere.

I'm pretty sure that does not belong there.

It may have been inserted as an aberration of an ASCII ftp transfer or a glitched cut&paste.

Later,
Chris
Sun, 26 June 2011 22:44 Go to previous messageGo to next message
Registered: March 2011
Messages: 16
Hello Again,

I double-checked, and yes indeed, the "@" exists and the form works elsewhere.

I thought I'd try to find a different PHP script online to handle my contact form, and came across the website that my friend must have used (http://www.freecontactform.com/email_form.php) and the "@" is there, too! I'll try and credit another PHP developer and see if a simpler script makes a difference.

I'll keep you posted,
Mindy : )
Fri, 15 July 2011 23:53 Go to previous message
Registered: March 2011
Messages: 16
Hello Again,

So, after making the link that a bunch of "out of memory" fatal errors were related to running spam assassin, I did a clean re-install of my VPS and started again from scratch. Things are back to where they used to be, and I've got a new PHP script running my contact form page.

The script is running fine, accepting the form data, composing the email and sending it, and then showing the user a "thanks" page. The problem is, I'm not receiving the email. I'm able to find it in my control panel under the Mail Queue, and it shows that an error occurred while attempted to send the email. I have verified that I'm able to send and receive emails with the account (both through the webmail program as well as with Outlook).

Here's the bounced message I'm receiving (copied from the Mail Queue) where "infinitivehost" is the name of the VPS. Also, I'm using an alternate SMTP port of 587. I'm not sure if that has to be listed somewhere in my PHP script.

--------------
MESSAGE NUMBER 31719753
--------------
Received: (qmail 11725 invoked for bounce); 15 Jul 2011 21:08:35 -0000
Date: 15 Jul 2011 21:08:35 -0000
From: MAILER-DAEMON@infinitivehost
To: anonymous@infinitivehost.infinitivehost
Subject: failure notice

Hi. This is the qmail-send program at infinitivehost.
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.

<mindy@ruralsquirrel.ca>:
Connected to 66.96.142.52 but sender was rejected.
Remote host said: 550 5.1.0 error: R4.1: 76.74.129.202

--- Below this line is a copy of the message.

Return-Path: <anonymous@infinitivehost.infinitivehost>
Received: (qmail 11721 invoked by uid 1006); 15 Jul 2011 21:08:34 -0000
Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws;
s=private; d=mindypostoff.com;
b=mAUug727Tmzeuz7L0PuK9TXofsNLmBzha/XfI6QepwmmnPaX4ztGHygcns I8OJYl;
Date: 15 Jul 2011 21:08:34 -0000
Message-ID: <20110715210834.11716.qmail@infinitivehost>


Thanks in advance for any light that can be shed on this issue,
Mindy Smile
Previous Topic:Stuck on Jaunty and can't upgrade or add packages... help?
Next Topic:PHP Mail() needs PEAR?
Goto Forum:
  


Current Time: Thu Nov 23 11:37:44 EST 2017
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7.
Copyright ©2001-2006 FUD Forum Bulletin Board Software