If you're using the Astra theme then you need to create a file with any name.php and
copy this and past it file save it.
now create a page then select template "CustomPageT1" you can change this name.
If you are not using Astra than use the second method -
<?php
/**
* The template for displaying all single posts.
*Template Name: CustomPageT1
*Author name: shyamsir (sknetking)
* @link https://sknetking9.blogspot.com
*
* @package Astra
* @since 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
get_header(); ?>
<style>
.container {
border-radius: 5px;
background-color: #f2f2f2;
padding: 20px;
}
input[type=text], select, textarea,email {
width: 100%;
padding: 12px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
margin-top: 6px;
margin-bottom: 16px;
resize: vertical;
}
</style>
<script>
if ( window.history.replaceState ) {
window.history.replaceState( null, null, window.location.href );
}
</script>
<h3>Contact Form</h3>
<div class="container">
<form method="post" >
<label for="name">Full Name</label>
<input type="text" id="name" name="fname" placeholder="Your name..">
<label for="email">Your E-mail</label>
<input type="text" id="email" name="email" placeholder="Your gmail..">
<label for="country">Country</label>
<select id="country" name="country">
<option value="india">India</option>
<option value="Russia">Russia</option>
<option value="usa">USA</option>
</select>
<label for="subject">Massage</label>
<textarea id="subject" name="subject" placeholder="Write something.." style="height:200px"></textarea>
<input type="submit" value="Submit" name="submit">
</form>
</div>
<?php
if(isset($_POST['submit'])){
$tomail = get_option( 'admin_email' );//$_POST['email'];
$body = $_POST['fname']." From ".$_POST['country']." <br/>".$_POST["subject"];
$headers = array('Content-Type: text/html; charset=UTF-8');
$mailResult =false;
$mailResult = wp_mail($tomail ,"Mr./Ms.".$_POST['fname'], $body,$headers);
if($mailResult)
echo "Massage send successfuly";
else
echo "Something went worng";
}
// define variables and set to empty values
?>
</div><!-- #primary -->
<?php get_footer(); ?>
Second method :
If you are using any other theme than please copy only
blue color text and past step by step using PHP syntax
Your custom contact-us page ready to use but remember you also need to setup
SMTP ok.
Note:- If you like this post then comment below.
0 Comments