Your code is ok! Please check other javascript/jquery plugins or change your browser some times some of the extensions in Google chrome create such kind of errors.
Thanks!
Have a nice day.
Solution 1 :
Problem :
I am trying to execute php with a html form but I get the following output to the console.
[Fri Sep 18 13:04:38 2020] [::1]:59753 Accepted
[Fri Sep 18 11:04:38 2020] [404] /php/contactform-process.php – No
such file or directory [Fri Sep 18 13:04:38 2020] [::1]:59753 [404]:
POST /php/contactform-process.php – No su ch file or direc tory[Fri Sep 18 13:04:38 20 20] [::1]:59753 Closing
This is my code
<?php
if(isset($_POST['submit'])){
$to = "[email protected]";
$from = $_POST['email'];
$subject = $_POST['subject'];;
$message = $_POST['message'];
var_dump($to);
var_dump($from);
var_dump($subject);
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
}
?>
<!-- Contact Form -->
<div class="col-lg-6">
<form id="ContactForm" data-toggle="validator" action="" method="post">
<div class="form-group">
<input type="email" name="email" class="form-control-input" id="cemail" placeholder="Email" required>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<input type="text" name="subject" class="form-control-input" id="csubject" placeholder="Subject" required>
<div class="help-block with-errors"></div>
</div>
<div class="form-group textarea">
<textarea type="text" name="message" class="form-control-textarea" id="cmessage" placeholder="Write your message here"></textarea>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<input type="submit" value="Submit" class="form-control-submit-button"></input>
</div>
<div class="form-message">
<div id="msgCSubmit" class="h3 text-center hidden"></div>
</div>
</form>
</div>
I am using vscode with the php server plugin. I am running PHP 7.4
Comments
Comment posted by Levi Cole
Are you using javascript/ajax to post the form?
Comment posted by stackoverflow.com/questions/18379238/…
No, should I? I thought that this was built in to the form. From what I read here
Comment posted by Levi Cole
No javascript isn’t required. I was just wondering because your html form doesn’t include an
Comment posted by CBroe
“But in the question I referenced is clarified that action with a php file doesn’t work in html5”
Comment posted by anonymous-dev
@CBroe I removed my last comment. I miss read. Anyway I tried both ways with and wihout an action and it gave the same result.