Replace this file to your /test/app/design/frontend/base/default/template/contacts/form.phtml
<script type="text/javascript">
function ram_mk()
{
a=document.getElementById('tot').value;
b=document.getElementById('catcha').value;
if(a!=b)
{
document.getElementById('mk_x').style.display='';
return false;
}
}
function akk()
{
ab=Math.floor((Math.random()*10)+1);
ab1=Math.floor((Math.random()*8)+1);
var tot=ab+ab1;
document.getElementById('captcha_1').innerHTML=ab;
document.getElementById('captcha_2').innerHTML=ab1;
document.getElementById('tot').value=tot;
document.getElementById('ab').value=ab;
document.getElementById('ab1').value=ab1;
}
window.onload = akk;
</script>
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category design
* @package base_default
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
?>
<div class="middle_a">
<?php if($_REQUEST['msg']!='') { ?>
<ul class="messages"><li class="success-msg"><ul><li><span><?php echo $_REQUEST['msg']; ?></span></li></ul></li></ul>
<?php } ?>
<div class="contact_page">
<h3><?php echo Mage::helper('contacts')->__('got questions?') ?></h3>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('contact-us')->toHtml() ?>
<div class="contact_form">
<form action="http://yourdomain.com/email.php" method="post">
<input type="hidden" name="url_x" value="<?php echo $currentUrl = Mage::helper('core/url')->getCurrentUrl() ?>" />
<table width="100%" border="0" cellspacing="0" cellpadding="10">
<tr>
<td><input name='name' type='text' class="text-df" onblur="if(this.value=='') this.value='Your Name'" onfocus="if(this.value=='Your Name') this.value=''" value="Your Name" required="required"/></td>
</tr>
<tr>
<td><input name='email' type='email' class="text-df" onblur="if(this.value=='') this.value='Email Address'" onfocus="if(this.value=='Email Address') this.value=''" value="Email Address" required="required"/></td>
</tr>
<tr>
<td><textarea name="Message" class="box-df1" required="required" onblur="if(this.value=='') this.value='Message'" onfocus="if(this.value=='Message') this.value=''" value="Message" >Message</textarea>
</td>
</tr>
<tr>
<td><input name="catcha" id="catcha" type='text' class="text-df" onblur="if(this.value=='') this.value='Enter Sum'" onfocus="if(this.value=='Enter Sum') this.value=''" value="Enter Sum" /></td>
</tr>
<tr style="display:none; color:#CC0000;" id="mk_x">
<td align="center">Captcha not match</td>
</tr>
<tr>
<td>
<table width="100%">
<tr>
<td id="captcha-x">
<span id="captcha_1">8</span> + <span id="captcha_2">5</span> = ?
<input type="hidden" name="tot" id="tot" value="15" size="2"/>
<input type="hidden" name="ab" id="ab" value="15" size="2"/>
<input type="hidden" name="ab1" id="ab1" value="15" size="2"/>
</td>
<td align="right">
<input type='submit' name="submit" value="Send" class="send" onclick="return ram_mk();" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!-- contact_page -->
</div>
<!-- middle_a -->
<script type="text/javascript">
//<![CDATA[
var contactForm = new VarienForm('contactForm', true);
//]]>
</script>
and add this file with name email.php to your magento root folder:
<?php
$catcha = $_REQUEST['catcha'];
$tot =$_REQUEST['tot'];
$ab = $_REQUEST['ab'];
$ab1 = $_REQUEST['ab1'];
$total=$ab+$ab1;
if($tot=='@100as_pti')
{
print("<script>window.location='".$_REQUEST['url_x']."'</script>");
exit;
}
if($catcha!=$total)
{
print("<script>window.location='".$_REQUEST['url_x']."'</script>");
exit;
}
if($catcha==$total)
{
$mesg = $_REQUEST['Message'];
if(stristr($mesg, 'http') === FALSE)
{
if(stristr($mesg, 'https') === FALSE)
{
$_session['success']="Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us";
$replymsg="Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us";
$mail_to="shweta@ptiwebtech.com";
$sub="Contact us ";
$message = "<br>Name : ".$_REQUEST['name'];
$message .= "<br>E-mail : ".$_REQUEST['email'];
$message .= "<br>Message : ".$_REQUEST['Message'];
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .="From: ".$_REQUEST['email'];
mail($mail_to,$sub,$message,$headers);
}
}
}
print("<script>window.location='".$_REQUEST['url_x']."?msg=$replymsg'</script>");
?>
NOTE: replace $mail_to="shweta@ptiwebtech.com"; to your email id.