Form not submitting values


Form not submitting values



Ok so, I am a self taught coder, so no need to be overly rude if I am missing something lol. This is the first ever form I have created, and I have the css, html, and php set up. My issue is whenever I hit the submit button, all it does is reload the page and sends no data. I have honestly checked out the other forums here for answers but the things I have found in other forums, I have tried, but it hasn't worked. I will leave my code below, if anyone could tell me why its not submitting the values that would be a huge help.


<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Contact Us">
<meta name="keywords" content="Contact Us">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="HandheldFriendly" content="true">
<link href="https://fonts.googleapis.com/css?family=Barlow+Condensed" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="ContactUs.css">
<link href="style.css" rel="stylesheet" />
<!--[if IE 6]>
<style type="text/css">html .group { height: 1%; }</style>
<![endif]-->
<!--[if IE 7]>
<style type="text/css">*:first-child+html .group { min-height: 1px; } </style>
<![endif]-->
<!--[if lt IE 9]>
https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js
<![endif]-->
</head>



This is my HTML











">











</div>
</form>
</div>



This is my PHP


<?php
if(isset($_POST['submit'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name n Message: $message";
$recipient = "searaadair@hotmail.com";
$subject = "Contact Form";
$mailheader = "From: $email rn";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
}
?>





Most likely lucumts answer is correct but without seeing the full picture it's impossible to know. Where is your PHP located in the document? Can you post the full code? There are some other issues I see in the html. For example, the tag <html> is in the middle of the code.
– John T
Jun 30 at 3:04





Also, is that HTML actually in a PHP file? If not, your form is pointing to an invalid URL and won't actually POST anywhere.
– Nathan Heffley
Jun 30 at 3:11





Yes, my html and PHP are in a PHP file, and the php is located at the bottom of the code. I have a hunch that it might need to be put somewhere else, am I right about that? Or does that matter? and thanks John. I removed that!
– Seara Adair
Jun 30 at 3:14





I updated with rest of my code, minus CSS, as I don't think that is the issue
– Seara Adair
Jun 30 at 3:31





@JohnT yes, thank you! I read my error logs to and found a couple other things and changed those. Thanks for the help!
– Seara Adair
yesterday




2 Answers
2



Try to use this for your PHP template. I noticed some were missing their closing tags, so I fixed that. The most peculiar issue was how you had two tags, and only one of them were closing. These two lines here...




">



Must be inside the same tag.


" class="form" id="form1">



Try it with the following PHP. You also had a strange stray tag.
















" class="form" id="form1">














</div>
</form>
</div>
</div>





Thank you for that, I tried replacing it with what you provided and unfortunately I am still not able to get it to work....
– Seara Adair
Jun 30 at 4:32



Ensure that your HTML have the .php file extension, since you are printing $_SERVER['PHP_SELF'] on the form's action attribute. That will not happen if you're using .html as file extension. I also noticed that you seemed to be using a javascript validation plugin (through the class attribute), double check the submit event for that as well.


.php


$_SERVER['PHP_SELF']


action


.html


class





it is correctly named, it us under formmail.php. I am probably going to remove the validation for now actually, so I will see if that changes anything. Will add it back when I can at least get the form to submit lol
– Seara Adair
Jun 30 at 4:29





how did it go? were you able to solve your issue?
– ubuntux
yesterday






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

how to run turtle graphics in Colaboratory

Export result set on Dbeaver to CSV