Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
Internal Server Error - Contact Forms???
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="GarettM" data-source="post: 378553" data-attributes="member: 839"><p>Hmm without seeing more source code it is kinda hard to figure out what the real issue for the 500 Internal Server Error is. The only thing that catches my eye is the line</p><p>[PHP]</p><p>$mail_status = mail($mail_to, $subject, $body_message, $headers);</p><p>[/PHP]</p><p>Also everything else about this script is wrong...</p><p></p><p>For the HTML you have the fallowing</p><p>[CODE]</p><p><form action="mail.php" method="POST"></p><p> Name <input type="text" name="name"></p><p> E-Mail<input type="text" name="email"></p><p> Message<textarea name="message" rows="6" cols="25"></textarea><br /></p><p> <input type="submit" value="Send"><input type="reset" value="Clear"></p><p></form></p><p>[/CODE]</p><p>That gives you the fallowing GET data</p><p>[CODE]</p><p>Array(</p><p> 'name' => '',</p><p> 'email' => '',</p><p> 'message' => '',</p><p> 'submit' => true,</p><p>)</p><p>[/CODE]</p><p></p><p>But instead your using different GET key names like 'cf_name', 'cf_email', 'cf_*', ...etc, so maybe in a weird way the error is from out of bound array error?</p><p></p><p>Another thing that comes to mind is when PHP errors are turned off sometimes it is possible to set it up where if there is an error just show a 500 error kinda like what IIS does.</p><p></p><p>Been awhile but try this see if it works better</p><p>[PHP]</p><p><?php</p><p> /**</p><p> * Simple Send Mail Script</p><p> */</p><p></p><p>/**</p><p> * Filter Data.</p><p> */</p><p>function filter($input, $filter = FILTER_DEFAULT)</p><p>{</p><p> return filter_var($key, $filter);</p><p>}</p><p>/**</p><p> * Clean Input Information.</p><p> */</p><p>function clean($input)</p><p>{</p><p> return stripslashes(strip_tags(htmlspecialchars($input, ENT_IGNORE, 'utf-8')));</p><p>}</p><p></p><p>$field_name = filter($_POST['name']) ? clean($_POST['name']) : null;</p><p>$field_email = filter($_POST['email'], FILTER_VALIDATE_EMAIL) ? clean($_POST['email']) : null;</p><p>$field_message = filter($_POST['message']) ? clean($_POST['message']) ? null;</p><p></p><p>$mail_to = "contact@garettm.tech";</p><p>$subject = "Message from visitor";</p><p></p><p>$body_message = sprintf("From: %s\nE-Mail: %s\nMessage: %s\n", $field_name, $field_email, $field_message);</p><p>$headers = sprintf("From: %1\nReply-To: %1\n", $field_email);</p><p></p><p>$mail_status = !is_null($field_name) && !is_null($field_email) && !is_null($field_message) ? mail($mail_to, $subject, $body_message, $headers) : false;</p><p></p><p>echo '<script language="javascript" type="text/javascript">', (($mail_status) ? 'alert("Thank you for your message.");' : 'alert("Message Failed");'), 'window.location = "index.php";</script>';</p><p>exit;</p><p>[/PHP]</p><p>[doublepost=1467355462,1467355441][/doublepost]Hmm without seeing more source code it is kinda hard to figure out what the real issue for the 500 Internal Server Error is. The only thing that catches my eye is the line</p><p>[PHP]</p><p>$mail_status = mail($mail_to, $subject, $body_message, $headers);</p><p>[/PHP]</p><p>Also everything else about this script is wrong...</p><p></p><p>For the HTML you have the fallowing</p><p>[CODE]</p><p><form action="mail.php" method="POST"></p><p> Name <input type="text" name="name"></p><p> E-Mail<input type="text" name="email"></p><p> Message<textarea name="message" rows="6" cols="25"></textarea><br /></p><p> <input type="submit" value="Send"><input type="reset" value="Clear"></p><p></form></p><p>[/CODE]</p><p>That gives you the fallowing GET data</p><p>[CODE]</p><p>Array(</p><p> 'name' => '',</p><p> 'email' => '',</p><p> 'message' => '',</p><p> 'submit' => true,</p><p>)</p><p>[/CODE]</p><p></p><p>But instead your using different GET key names like 'cf_name', 'cf_email', 'cf_*', ...etc, so maybe in a weird way the error is from out of bound array error?</p><p></p><p>Another thing that comes to mind is when PHP errors are turned off sometimes it is possible to set it up where if there is an error just show a 500 error kinda like what IIS does.</p><p></p><p>Been awhile but try this see if it works better</p><p>[PHP]</p><p><?php</p><p> /**</p><p> * Simple Send Mail Script</p><p> */</p><p></p><p>/**</p><p> * Filter Data.</p><p> */</p><p>function filter($input, $filter = FILTER_DEFAULT)</p><p>{</p><p> return filter_var($key, $filter);</p><p>}</p><p>/**</p><p> * Clean Input Information.</p><p> */</p><p>function clean($input)</p><p>{</p><p> return stripslashes(strip_tags(htmlspecialchars($input, ENT_IGNORE, 'utf-8')));</p><p>}</p><p></p><p>$field_name = filter($_POST['name']) ? clean($_POST['name']) : null;</p><p>$field_email = filter($_POST['email'], FILTER_VALIDATE_EMAIL) ? clean($_POST['email']) : null;</p><p>$field_message = filter($_POST['message']) ? clean($_POST['message']) ? null;</p><p></p><p>$mail_to = "contact@garettm.tech";</p><p>$subject = "Message from visitor";</p><p></p><p>$body_message = sprintf("From: %s\nE-Mail: %s\nMessage: %s\n", $field_name, $field_email, $field_message);</p><p>$headers = sprintf("From: %1\nReply-To: %1\n", $field_email);</p><p></p><p>$mail_status = !is_null($field_name) && !is_null($field_email) && !is_null($field_message) ? mail($mail_to, $subject, $body_message, $headers) : false;</p><p></p><p>echo '<script language="javascript" type="text/javascript">', (($mail_status) ? 'alert("Thank you for your message.");' : 'alert("Message Failed");'), 'window.location = "index.php";</script>';</p><p>exit;</p><p>[/PHP]</p></blockquote><p></p>
[QUOTE="GarettM, post: 378553, member: 839"] Hmm without seeing more source code it is kinda hard to figure out what the real issue for the 500 Internal Server Error is. The only thing that catches my eye is the line [PHP] $mail_status = mail($mail_to, $subject, $body_message, $headers); [/PHP] Also everything else about this script is wrong... For the HTML you have the fallowing [CODE] <form action="mail.php" method="POST"> Name <input type="text" name="name"> E-Mail<input type="text" name="email"> Message<textarea name="message" rows="6" cols="25"></textarea><br /> <input type="submit" value="Send"><input type="reset" value="Clear"> </form> [/CODE] That gives you the fallowing GET data [CODE] Array( 'name' => '', 'email' => '', 'message' => '', 'submit' => true, ) [/CODE] But instead your using different GET key names like 'cf_name', 'cf_email', 'cf_*', ...etc, so maybe in a weird way the error is from out of bound array error? Another thing that comes to mind is when PHP errors are turned off sometimes it is possible to set it up where if there is an error just show a 500 error kinda like what IIS does. Been awhile but try this see if it works better [PHP] <?php /** * Simple Send Mail Script */ /** * Filter Data. */ function filter($input, $filter = FILTER_DEFAULT) { return filter_var($key, $filter); } /** * Clean Input Information. */ function clean($input) { return stripslashes(strip_tags(htmlspecialchars($input, ENT_IGNORE, 'utf-8'))); } $field_name = filter($_POST['name']) ? clean($_POST['name']) : null; $field_email = filter($_POST['email'], FILTER_VALIDATE_EMAIL) ? clean($_POST['email']) : null; $field_message = filter($_POST['message']) ? clean($_POST['message']) ? null; $mail_to = "contact@garettm.tech"; $subject = "Message from visitor"; $body_message = sprintf("From: %s\nE-Mail: %s\nMessage: %s\n", $field_name, $field_email, $field_message); $headers = sprintf("From: %1\nReply-To: %1\n", $field_email); $mail_status = !is_null($field_name) && !is_null($field_email) && !is_null($field_message) ? mail($mail_to, $subject, $body_message, $headers) : false; echo '<script language="javascript" type="text/javascript">', (($mail_status) ? 'alert("Thank you for your message.");' : 'alert("Message Failed");'), 'window.location = "index.php";</script>'; exit; [/PHP] [doublepost=1467355462,1467355441][/doublepost]Hmm without seeing more source code it is kinda hard to figure out what the real issue for the 500 Internal Server Error is. The only thing that catches my eye is the line [PHP] $mail_status = mail($mail_to, $subject, $body_message, $headers); [/PHP] Also everything else about this script is wrong... For the HTML you have the fallowing [CODE] <form action="mail.php" method="POST"> Name <input type="text" name="name"> E-Mail<input type="text" name="email"> Message<textarea name="message" rows="6" cols="25"></textarea><br /> <input type="submit" value="Send"><input type="reset" value="Clear"> </form> [/CODE] That gives you the fallowing GET data [CODE] Array( 'name' => '', 'email' => '', 'message' => '', 'submit' => true, ) [/CODE] But instead your using different GET key names like 'cf_name', 'cf_email', 'cf_*', ...etc, so maybe in a weird way the error is from out of bound array error? Another thing that comes to mind is when PHP errors are turned off sometimes it is possible to set it up where if there is an error just show a 500 error kinda like what IIS does. Been awhile but try this see if it works better [PHP] <?php /** * Simple Send Mail Script */ /** * Filter Data. */ function filter($input, $filter = FILTER_DEFAULT) { return filter_var($key, $filter); } /** * Clean Input Information. */ function clean($input) { return stripslashes(strip_tags(htmlspecialchars($input, ENT_IGNORE, 'utf-8'))); } $field_name = filter($_POST['name']) ? clean($_POST['name']) : null; $field_email = filter($_POST['email'], FILTER_VALIDATE_EMAIL) ? clean($_POST['email']) : null; $field_message = filter($_POST['message']) ? clean($_POST['message']) ? null; $mail_to = "contact@garettm.tech"; $subject = "Message from visitor"; $body_message = sprintf("From: %s\nE-Mail: %s\nMessage: %s\n", $field_name, $field_email, $field_message); $headers = sprintf("From: %1\nReply-To: %1\n", $field_email); $mail_status = !is_null($field_name) && !is_null($field_email) && !is_null($field_message) ? mail($mail_to, $subject, $body_message, $headers) : false; echo '<script language="javascript" type="text/javascript">', (($mail_status) ? 'alert("Thank you for your message.");' : 'alert("Message Failed");'), 'window.location = "index.php";</script>'; exit; [/PHP] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
Internal Server Error - Contact Forms???
Top