Mailto contact form

<form class="form">
										<input class="name" type="text" placeholder="Name">
										<input class="email" type="email" placeholder="Email">
										<input class="phone" type="text" placeholder="Phone No:">
										<textarea class="message" name="message" id="message" cols="30" rows="10" placeholder="Message"></textarea>
									<a href="mailto:ryan@example.com"><input class="submit-btn" type="submit" value="Send"></a>
									</form>
								</div>

not really sure what im doing wrong could i please get some help with this , Thank you

This is not how form-mail works.
Generally any such form will utilise some type of back-end or server-side scripting to process the submission, such as PHP.
If on the other hand you just want a link to your email, that can be done using the <a> tag with mailto in the href like you have, only without any form input within it. The downside of that is it does not protect from spam. As you have it, the address is there in the visible code, so is vulnerable to spam, so no point in using a form in such a way.

If you are not confident enough with server-side scripting to create your own processing script, you could use a pre-made script such as this one:-

3 Likes

Hello @ryfizzle You can do it in following way:-

<?php    
if(isset($_POST['submitbtn']))
{ 
$name = $_POST['contactname'];
$email= $_POST['email'];
$phone= $_POST['phone'];
$message= $_POST['message'];

if(isset($_POST['email'])) 
{
$email_to = "adminemailid@email.com";
$subject="Subject of mail";

$headers = 'From: '.$email."\r\n". 
'Reply-To: '.$email."\r\n" .
'X-Mailer: PHP/' . phpversion();

@mail($email_to, $email_subject,$message, $headers);  
}
}    
?>






 

You must use various other functions to check the validation and all that, but yes this code can send basic email.

Without any form validation?

yes, that’s right. We must use authentication. Actually I just given a simple code, but agree with you, authentication must me there

We appreciate your willingness to help, @enpriya, but you need to remember that many people reading these topics will be complete beginners, and may be misled or confused by partial solutions. If you’re posting code, please ensure it is valid and usable “as is”, without the need for extra knowledge.

As @SamA74 says, there are various ready-made options available to use, which may be more suitable for a beginner.

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.