Hi guys, I was testing a way to send the form inputs to my email through a .php way.
I’ve never written in PHP so I don’t have a clue on where to begin.
My HTML code for the form is:
<div class="w-form">
<form id="email-form" name="email-form" data-name="Email Form" method="post" action="sendform.php" class="form">
<label for="name-2">Name Field</label>
<input type="text" id="test-name" name="name" data-name="name" maxlength="256" class="w-input">
<label for="email">Email Field</label>
<input type="email" class="w-input" maxlength="256" name="email" data-name="Email" id="test-email" required="">
<textarea id="test-text-1" name="text" placeholder="Example Text" maxlength="5000" data-name="text" class="w-input">
</textarea>
<div class="w-checkbox"><input type="checkbox" id="test-checkbox" name="checkbox" data-name="Checkbox" required="" class="w-checkbox-input">
<label for="checkbox" class="w-form-label">Checkbox</label>
</div><input type="text" class="w-input" maxlength="256" name="text-2" data-name="text-2" placeholder="Example Text" id="test-text-2" required="">
<select id="test-choice" name="scelta" data-name="scelta" class="w-select">
<option value="">Select one...</option>
<option value="First">First Choice</option>
<option value="Second">Second Choice</option>
<option value="Third">Third Choice</option>
</select><input type="submit" value="Submit" data-wait="Please wait..." class="w-button">
</form>
<div class="w-form-done">
<div>Thank you! Your submission has been received!</div>
</div>
<div class="w-form-fail">
<div>Oops! Something went wrong while submitting the form.</div>
</div>
</div>
And this is what I’ve been writing until now in PHP:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$formcontent="From: $name \n Message: $message";
$recipient = "test@email.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); echo "Thank You!";
?>
I’m still missing some code on the PHP file to get all infos submitted, can any hero please help me?