খুব সহজেই acordian Contact Us বাটন যুক্ত করুন আপনার ওয়ার্ডপ্রেস সাইটে।

টেকটিউনসের পাঠকরা আশা করি ভালো আছেন। আমি আজ হাজির হয়েছি একটি contact us বাটন নিয়ে। বাটনটি ‍যুক্ত সহজে আপনার ওয়ার্ডপ্রেস সাইটে যুক্ত করতে পারেন।

আপনারা আমার এই সাইটটি থেকে ডেমো দেখে আসতে পারেন। WordPress Theme Development এই কাজটি করতে আপনাকে বেশি কষ্ট করতে হবেনা। শুধু নিচের php code  কপি করে আপনি যেখানে সেট করতে চান সেখানে পেস্ট করুন। তবে একটি কথা আপনার থিমে অবশ্যই bootistrap call করা থাকতে হবে, তা না হলে বাটনটি কাজ করবেনা।

<!-- Contact Form-->
<div>
<a data-toggle="collapse" data-parent="#accordion" href="#collapseone1">
<div>
<h2><span>+</span>Contact Us</h2>
</div>
</a>
<div id="collapseone1">

<!-- contact form-->
<?php
//If the form is submitted
if(isset($_POST['submitted'])) {

//Check to see if the honeypot captcha field was filled in
if(trim($_POST['checking']) !== '') {
$captchaError = true;
} else {

//Check to make sure that the name field is not empty
if(trim($_POST['contactName']) === '') {
$nameError = 'You forgot to enter your name.';
$hasError = true;
} else {
$name = trim($_POST['contactName']);
}

//Check to make sure that a valid email address is submitted
if(trim($_POST['email']) === '')  {
$emailError = 'You forgot to enter your email address.';
$hasError = true;
} else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) {
$emailError = 'You entered an invalid email address.';
$hasError = true;
} else {
$email = trim($_POST['email']);
}

//Check to make sure comments were entered
if(trim($_POST['comments']) === '') {
$commentError = 'You forgot to enter your comments.';
$hasError = true;
} else {
if(function_exists('stripslashes')) {
$comments = stripslashes(trim($_POST['comments']));
} else {
$comments = trim($_POST['comments']);
}
}

//If there is no error, send the email
if(!isset($hasError)) {

$emailTo = '[email protected]';
$subject = 'Contact Form Submission from '.$name;
$sendCopy = trim($_POST['sendCopy']);
$body = "Name: $name \n\nEmail: $email \n\nComments: $comments";
$headers = 'From: My Site <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;mail($emailTo, $subject, $body, $headers);

if($sendCopy == true) {
$subject = 'You emailed Your Name';
$headers = 'From: Your Name <[email protected]>';
mail($email, $subject, $body, $headers);
}

$emailSent = true;

}
}
} ?>

<?php if(isset($emailSent) && $emailSent == true) { ?>

<div>
<h1>Thanks, <?=$name;?></h1>
<p>Your email was successfully sent. We will be in touch soon.</p>
</div>

<?php } else { ?>
<?php if(isset($hasError) || isset($captchaError)) { ?>
<p>There was an error submitting the form.<p>
<?php } ?>

<form action="" id="contactForm" method="post">

<ol>
<li><label for="contactName">Name</label>
<input type="text" name="contactName" id="contactName" value="<?php if(isset($_POST['contactName'])) echo $_POST['contactName'];?>" />
<?php if($nameError != '') { ?>
<span><?=$nameError;?></span>
<?php } ?>

<li><label for="email">Email</label>
<input type="text" name="email" id="email" value="<?php if(isset($_POST['email']))  echo $_POST['email'];?>" />
<?php if($emailError != '') { ?>
<span><?=$emailError;?></span>
<?php } ?>
</li>

<li><label for="commentsText">Comments</label>
<textarea name="comments" id="commentsText" rows="4" cols="30"><?php if(isset($_POST['comments'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['comments']); } else { echo $_POST['comments']; } } ?></textarea>
<?php if($commentError != '') { ?>
<span><?=$commentError;?></span>
<?php } ?>
</li>
<li><input type="checkbox" name="sendCopy" id="sendCopy" value="true"<?php if(isset($_POST['sendCopy']) && $_POST['sendCopy'] == true) echo ' checked="checked"'; ?> /><label for="sendCopy">Send a copy of this email to yourself</label></li>
<li><input type="hidden" name="submitted" id="submitted" value="true" /><button type="submit">Submit &raquo;</button></li>
</ol>
</form>
<?php } ?>

<!-- End contact form-->

 

আমি নিচের সিএসএস টুকু ব্যবহার করেছি। আপনি আপনার সুবিধা মত ব্যবহার করতে পারেন।

/* contact form*/
.contact_form_area {
margin-top: 6px;
position: absolute;
right: 139px;
z-index: 999999;
}
.contact_us{
margin-left: 195px;

}
.contact_us h2{
background: none repeat scroll 0 0 #006699;
color: #fff;
font-size: 15px;
margin: 0;
padding: 4px;
font-family: 'Ubuntu', sans-serif;}
.contact_us span{color: #003366;
font-weight: bold;
margin-right: 3px;}

সবায় ভালো থাকবেন। আল্লাহ হাফেজ।।।।।।।।।।।।।।।।।।।।।।।।।।।।।।।।।।

পোষ্টটি ভালো লাগলে আমার এখানে একটা লাইক দিতে পারেন।    Facebook page

 

Level 0

আমি টেক পাগল। বিশ্বের সর্ববৃহৎ বিজ্ঞান ও প্রযুক্তির সৌশল নেটওয়ার্ক - টেকটিউনস এ আমি 9 বছর 6 মাস যাবৎ যুক্ত আছি। টেকটিউনস আমি এ পর্যন্ত 13 টি টিউন ও 38 টি টিউমেন্ট করেছি। টেকটিউনসে আমার 0 ফলোয়ার আছে এবং আমি টেকটিউনসে 0 টিউনারকে ফলো করি।


টিউনস


আরও টিউনস


টিউনারের আরও টিউনস


টিউমেন্টস