Skip to main content
Participant
January 7, 2018
Answered

Simple .php mail form won't work?

  • January 7, 2018
  • 1 reply
  • 647 views

Hi all... I am graphic designer that is new to web design and am trying to create and email contact form on my website, however when i ftp upload and try to use the form it comes up with the following error - I have gone through a number of tutorials on the internet and nothing seems to fix this problem - can anyone help?-

is currently unable to handle this request.

HTTP ERROR 500

...here is the code...

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>contactform</title>

</head>

<body>

<?php

if (isset($_POST['submit'])){

$name=$_POST['name'];

$email=$_POST['email'];

$phone=$_POST['phone'];

$comment=$_POST['comment'];

$to='myemail@bigpond.com';

$subject='New Message';

$message="Name: ".$name."\n"."Phone: ".$phone."\n". "Wrote the following: "."\n\n".$comment;

$headers="From: ".$email;

if (mail($to, $subject, $comment, $headers)){

echo "Your Message has been sent"." ".$name.", We will contact you shortly!";

}

else{

echo "Something went wrong!";

}

}

?>

</body>

</html>

html code...

<div id="formwrapper">

                              <form action="contactform.php" method="post" name="form1" id="form1">

                              <p>

                                <span class="bodytextGrey">Full Name

                                </span>

                                <input name="name" type="text" required class="formstyle" id="name" form="form1" size="30">

                              </p>

                              <p>

                                <label for="email" class="bodytextGrey">Email*</label>

                                <input name="email" type="email" required class="formstyle" id="email" form="form1" size="34">

                              </p>

                              <p>

                                <label for="phone" class="bodytextGrey">Contact No.                              </label>

                                <input name="phone" type="tel" required class="formstyle" id="phone" form="form1" size="29">

                            </p>

                              <p>

                                <label for="comment"><span class="bodytextGrey">Comments</span><br>

                              </label>

                                <textarea name="comment" cols="53" rows="10" id="comment" form="form1"></textarea>

                                <label for="textfield2">                                  <br>

                                </label>

                              </p>

                              <table width="100%" border="0" cellspacing="0" cellpadding="0">

                                <tbody>

                                  <tr>

                                    <td align="center"><input name="submit" type="submit" class="submitbutton" id="submit" form="form1" formaction="form_process.php" formmethod="POST" value="Submit"></td>

                                  </tr>

                                </tbody>

                              </table>

                              <p> </p>

                          </form>

                           </div>

This topic has been closed for replies.
Correct answer BenPleysier

I think that your submit button contains erroneous code like the formaction which is different to action in the form element. I also think that security is going to be an issue if you persue with your code.

Have a look at what Nancy suggests at Alt-Web Design & Publishing: Responsive Contact Form with Bootstrap 3.2 and PHP (Part 1). Please ignore the Bootstrap stuff if you are not using it. Just read the article and take note of the PHP code.

1 reply

BenPleysier
Community Expert
BenPleysierCommunity ExpertCorrect answer
Community Expert
January 7, 2018

I think that your submit button contains erroneous code like the formaction which is different to action in the form element. I also think that security is going to be an issue if you persue with your code.

Have a look at what Nancy suggests at Alt-Web Design & Publishing: Responsive Contact Form with Bootstrap 3.2 and PHP (Part 1). Please ignore the Bootstrap stuff if you are not using it. Just read the article and take note of the PHP code.

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
Participant
January 7, 2018

Thank you, Ben...I will go check this out and see how i go.  Cheers.