0

The problem is the submit button, it's just unclickable, and nothing really happens (=screen doesn't change) when I am trying to submit an email to myself by using the form.

This is my code:

<div class="col-sm-6">
<h4 class="font-alt">Get in touch</h4>
<br>
<form id="contact-form" role="form" novalidate="">
<div class="form-group">
<label class="sr-only" for="cname">Name</label>
<input type="text" id="cname" class="form-control" name="cname"       placeholder="Name*" required="" data-validation-required-message="Please enter your name.">
<p class="help-block text-danger"></p>
</div>

<div class="form-group">
<label class="sr-only" for="cemail">Your Email</label>
<input type="email" id="cemail" name="cemail" class="form-control" placeholder="Your E-mail*" required="" data-validation-required-message="Please enter your email address.">
<p class="help-block text-danger"></p>
</div>

<div class="form-group">
<textarea class="form-control" id="cmessage" name="cmessage" rows="7" placeholder="Message*" required="" data-validation-required-message="Please enter your message."></textarea>
<p class="help-block text-danger"></p>
</div>

<div class="text-center">
<button type="submit" class="btn btn-block btn-round btn-d">Submit</button>
</div>

</form>
<div id="contact-response" class="ajax-response font-alt"></div>
</div>

And this is the PHP I'm working with:

<?php
// Mail settings
$to = "info@liannesiemensma.com";
$subject = "Contact form";
if (isset($_POST["name"]) && isset($_POST["email"]) && isset($_POST["message"])) {

$content  = "Name: "     . $_POST["name"]    . "\r\n";
$content .= "Email: "    . $_POST["email"]   . "\r\n";
$content .= "Message: "  . "\r\n" . $_POST["message"];

if (mail($to, $subject, $content, $_POST["email"])) {

$result = array(
"message" => "Thanks for contacting me! I will do my best to reply in a timely manner.",
"sendstatus" => 1
);

echo json_encode($result);
} else {

$result = array(
"message" => "Sorry, something is wrong.",
"sendstatus" => 0
);

echo json_encode($result);
}
}
?>

What am I doing wrong?

double-beep
  • 5,031
  • 17
  • 33
  • 41
  • 2
    Where is your PHP code? – Bubble Hacker May 25 '16 at 09:43
  • Where is your action="example.php" , please place action attribute in
    tag
    – Ramkee May 25 '16 at 09:44
  • What problem you are facing ? And, I think you are using framework. Can you please tell your framework name. – Nana Partykar May 25 '16 at 09:52
  • What do you mean by *it doesn't work*? It doesn't submit the form? It doesn't have an action attribute so in HTML5 it'll submit to itself. Submitting the form doesn't do anything? You get a PHP *"White Screen of Death"*? What, specifically, is the problem? – CD001 May 25 '16 at 09:53
  • I still wonder, why few people become `` after posting question.? – Nana Partykar May 25 '16 at 09:55
  • Thanks for all your comments! I've updated the post with the php code I'm using (I indeed use a framework). Furthermore, what I'll mean with it doesn't work is that the submit button just isn't clickable. So when I'll click it, the form isn't submitted and the screen just stays the same. – Lianne Siemensma May 25 '16 at 16:25

3 Answers3

0

write form tag action="fileName.php" and method

Ex: <form id="contact-form" role="form" novalidate="" action="#" method="post">

  • Not necessary in HTML5 : http://stackoverflow.com/questions/7048833/does-html5-require-an-action-attribute-for-forms – CD001 May 25 '16 at 09:58
0

actuly your form is submitting properly on same page just add

<?php
print_r($_GET);
?>

add this at first line and check

Navin Bhandari
  • 182
  • 1
  • 9
0

You are missing an action and method tags in your form declaration like this example:

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

Then you need to rename your file with extension .php and do some php processing in <?php ?> tags. You can validate your fields by utilising isset() method like this example:

isset($_POST["cname"])
K.I
  • 568
  • 1
  • 6
  • 19
  • In HTML5 (which this is - there's a placeholder attribute in use) *action* defaults to *self* and *method* to *get* - if they're missing it won't prevent the form submitting. – CD001 May 25 '16 at 10:02
  • Thank you for an update @CD001! In any case he is still missing his php code – K.I May 25 '16 at 10:06