I'm writing a simple splash page and using node's http-server
to test it out. When ever I click the "submit button it is suppose to send me an email, instead I get an error on the HTTP server console:
[Fri Jul 13 2018 10:02:37 GMT-0500 (Central Daylight Time)] "POST /" Error (404): "Not found"
Forgive me if this is simple but I'm not a web developer, here is my code:
<?php
if(isset($_POST['submit'])){
$to = "email@example.com";
$from = $_POST['email'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$subject = "Form submission";
$message = $first_name . " " . $last_name . " sent an email" . "\n\n";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
header('Location: thankyou.html');
}
?>
<!DOCTYPE html>
<head>
<meta http-equiv="=content-type" content="text/html"; charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Toby Inc.</title>
</head>
<body>
<table width="200" border="0">
<tbody><table Align="center">
<tr>
<th scope="col"><img src="logoNEW.jpg" width="580" height="710" alt=""/></th>
</tr>
</tbody>
</table>
<!-- You're probably going to want to play with this
since the form is aligned to the left side -->
<form action="" method="post">
Firstname: <input type="text" name="first_name"><br>
Last Name: <input type="text" name="last_name"><br>
Email: <input type="text" name="email"><br>
<input type="submit" name="submit" value="Submit to be inspired">
</form>
</body>
</html>
The thankyou.html file just says "Thank you"
What am I doing wrong?
Within the action
attribute of your form, you should specify the URL of the file it should post the data to.
If you want it to submit to the same page/URL, then remove the attribute entirely.
Do you have an SMTP Server installed?
Maybe this one can help you out: enter link description here
already mentioned: enter link description here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.