Hi there working on a simple contact form.
<form action="mail.php" method="POST">
<input type="text" id="name" name="name" placeholder="Name" required><br />
<input type="text" id="email" name="email" placeholder="Mail" required><br />
<textarea name="message" placeholder="Nachricht" required></textarea><br />
<button name="submit" type="submit" id="submit">send</button>
</form>
with a simple php mailer
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="Von: $name \n Nachricht: $message" ;
$recipient = "mail@mail.com";
$subject = "$betreff";
$mailheader = "Von: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" //need to be removed;
?>
Im using a simple javascript for changing the button to 'sending'
var send = document.getElementById('submit');
if(send) {
send.onclick = function () {
this.innerHTML = 'sending';
}
}
Is it possible to change the button innerhtml to sent
after the php script is successfully done? Also how can I avoid the redirection to the mail.php?
First it should show the send
. After clicking sending
should appear and when the mail.php is dont sent
should appear in the button.
Any ideas or suggestions?
best regards dennym
Edit: Further Progress and solution error on contact form submit via jquery ajax