I work as a teacher in adult education and I have developed sites (using Google Sites) for all of our courses at my school. I would like to take our sites a bit further by embedding some HTML elements to them.
One of the things I would like to embed is a feedback form. Since I am new to coding I have been working for a few days trying to get the form to work but I cannot seem to get it to work.
I would really appreciate if you guys could help me figure out what the issue is.
I know it might be very cluttered but this is what I managed to put together using Google Material Design Lite (paste the code here to see it: https://codepen.io/pen/):
<html>
<head>
<!-- Material Design Lite -->
<script src="https://code.getmdl.io/1.3.0/material.min.js"></script>
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css">
<!-- Material Design icon font -->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
</head>
<body>
<div class="contact-form">
<form id="contact-form" method="post" action="#">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input name="name" type="text" class="mdl-textfield__input" id="name">
<label class="mdl-textfield__label" for="name">Namn (frivligt)</label>
</div>
<br>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input name="course" type="text" class="mdl-textfield__input" id="course">
<label class="mdl-textfield__label" for="course">Kurs (frivligt)</label>
</div>
<br>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<textarea name="message" class="mdl-textfield__input" rows="7" id="message"></textarea>
<label class="mdl-textfield__label" for="message">Meddelande</label>
</div>
<br>
<input type="submit" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored" value="skicka">
</form>
</div>
</body>
</html>
This is the PHP I have written which I have linked with under action="#"
by uploading the php file to my github respiratory and linking to it with an URL.
<?php
if(isset($_POST['Submit'])) {
$name = $_POST['name'];
$course = $_POST['course'];
$message = $_POST['message'];
$mailTo = "name.lastname@domain.com";
$headers = "From: Site Form Submission";
mail($mailTo, $course, $message, $headers);
header("Location: index.php?mailsend");
}
?>
When I submit the form on the site a new tab opens in my browser that says 404 Invalid. When I go back to the site the entries in the form are still there. I have never used PHP before so I guess that is where the main issue lies.