I have a php based contact form on website. For form I have added alphanumeric captcha, now captcha js script working correctly but I didn’t receive email on email id . So basically if isset method is use for submission of form on email. For captcha jQuery is use for captcha validation. Trying to get email on email id from php based website.
$retval = false;
if (isset($_POST['submit']))
{
// if(tppp == 'abc')
// {}
// else
// {
$to = getDbValue("general_email", "tbl_settings", "id='1'"); // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$subject = "Miltec Contact Form";
$message = '<html><body>';
$message .= '<img src="http://www.milcomputing.com/images/logo.png" alt="Miltec logo" />';
$message .= '<h3> Miltec Contact Form </h3>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>".strip_tags($_POST['txtName'])."</td></tr>";
$message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_POST['email']) . "</td></tr>";
$message .= "<tr><td><strong>Phone:</strong> </td><td>".((intval($_POST["ddCountryPhoneCode"]) > 0)? getDbValue("CONCAT(`code`,' (+',isd_code,')')", "tbl_countries", "id='".$_POST["ddCountryPhoneCode"]."'")." " : "").strip_tags($_POST['phone'])."</td></tr>";
if (intval($_POST['ddDeviceRequired']) > 0)
$message .= "<tr><td><strong>Device Required:</strong> </td><td>".getDbValue("name", "tbl_device_required", "id='".$_POST['ddDeviceRequired']."'")."</td></tr>";
if (intval($_POST['ddApplicationSector']) > 0)
$message .= "<tr><td><strong>Application Sector:</strong> </td><td>".getDbValue("name", "tbl_application_sectors", "id='".$_POST['ddApplicationSector']."'")."</td></tr>";
$message .= "<tr><td><strong>Comments:</strong> </td><td>" . $_POST['comments'] . "</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
$headers = "From: " . strip_tags($_POST['email']) . "\r\n";
$headers .= 'Cc: demoprojecttestuser1@gmail.com' . "\r\n";
// $headers .= "CC:demoprojecttestuser1@gmail.com\r\n";
$headers .= "Reply-To: " . strip_tags($_POST['email']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$retval = mail($to, $subject, $message, $headers);
if ($retval == true)
redirect(SITE_URL."thank-you.html");
// }
}
?>
<div class="page-content">
<div class="page-overlay"></div>
<section id="section-overview" class="section-overview" data-nav-section="Overview">
<div class="container">
<div class="wrap ">
<div class="section-contact ">
<h1 class="cufon-din-light hl-lead"><?= $sTranslations["txt-contact-us"] ?></h1>
<div class="row" <?= (($_SESSION["LanguageId"] == 1)? 'dir="ltr" style="direction: ltr;"' : '') ?>>
<div class="col-md-6">
<div class="details-wrap">
<div class="label"> <img alt="Phone" src="images/icons/home-icon.png"><?= $sTranslations["txt-contact-us"] ?></div> <div>Miltec Rugged Computing Solutions L.L.C<br />
301-B, Al Nakheel Building,<br />
Al Karama,<br />
P.O Box - 126830,<br />
Dubai, UAE</div>
</div>
<div class="details-wrap">
<div class="label"> <img alt="Phone" src="images/icons/phone-icon.png"><?= $sTranslations["txt-phone"] ?></div> <div><?= $sTranslations["txt-tel-no"] ?>: +971 4 3795910<br />
<?= $sTranslations["txt-fax"] ?>: +971 4 3348182<br />
<?= $sTranslations["txt-email-address"] ?>: <a href="mailto:info@milcomputing.com">info@milcomputing.com</a></div>
</div>
</div>
<div class="col-md-6">
<div class="contact-wrap">
<!--<h4 class="align-center"><?= $sTranslations["txt-online-contact-form"] ?></h4>-->
<p class="align-center"><? //= $sTranslations["txt-get-latest-updates"] ?></p>
<div class="contact-form">
<!--<script>function wfa_pstMesgFrmFom (evt){if(evt.origin === 'https://crm.zoho.com'|| evt.origin === 'https://crm.zohopublic.com'){var loc_obj=JSON.stringify({ origin:window.location.origin, pathname:window.location.pathname, search:window.location.search, hash:window.location.hash}); evt.source.postMessage(('prnt_wnd_pg_lc_rc_frm_prwindow_'+loc_obj), evt.origin);}}window.addEventListener('message', wfa_pstMesgFrmFom, false);</script>
<iframe width='610px' height='490px' src='https://crm.zoho.com/crm/WebFormServeServlet?rid=8c03731b56ec80b8741b496de0433d9f0ad6181e6c87bcb49552a46364ad78ddgidfdddad8a32965ba8d08169c47e63374dc8b956d6c1f3b014f9c213fdf64ab167'></iframe>
--><form method="post" action="" class="" id="mktoForm_1050">
<div class="form-filed">
<label for="txtName" class="mktoLabel"><?= $sTranslations["txt-name"] ?>: <span class="required-star">*</span></label>
<input id="txtName" name="txtName" maxlength="255" type="text" class="mktoField" required>
</div>
<div class="form-filed">
<label for="Email" class="mktoLabel"><?= $sTranslations["txt-email-address"] ?>: <span class="required-star">*</span></label>
<input id="Email" name="email" maxlength="255" type="email" class="mktoField" required>
</div>
<div class="form-filed">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td width="138"><label for="Phone" class="mktoLabel"><?= $sTranslations["txt-phone"] ?>: <span class="required-star">*</span></label></td>
<td width="90">
<select name="ddCountryPhoneCode" id="ddCountryPhoneCode">
<option value=""></option>
<?
$sCountryCodeList = getList("tbl_countries", "id", "CONCAT(`code`,' (+',isd_code,')')", "status='A' AND isd_code!=''");
foreach ($sCountryCodeList as $iCountry => $sCode)
{
?>
<option value="<?= $iCountry ?>"><?= $sCode ?></option>
<?
}
?>
</select>
</td>
<td><input id="Phone" name="phone" maxlength="255" type="tel" class="mktoField" style="width:200px; margin-left: 10px;" required></td>
</tr>
</table>
</div>
<div class="form-filed">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="138"><label for="ddDeviceRequired" class="mktoLabel"><?= $sTranslations["txt-device-required"] ?>:</label></td>
<td>
<select name="ddDeviceRequired" id="ddDeviceRequired" >
<option value=""></option>
<?
$sDeviceRequired = getList("tbl_device_required a, tbl_device_required_data ad", "a.id", "ad.name", "a.status='A' AND a.id=ad.device_id AND ad.language_id='{$_SESSION["LanguageId"]}'");
foreach ($sDeviceRequired as $iDevice => $sDevice)
{
?>
<option value="<?= $iDevice ?>"><?= $sDevice ?></option>
<?
}
?>
</select>
</td>
</tr>
</table>
</div>
<div class="form-filed">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="138"><label for="ddApplicationSector" class="mktoLabel"><?= $sTranslations["txt-application-sector"] ?>: </label></td>
<td>
<select name="ddApplicationSector" id="ddApplicationSector" >
<option value=""></option>
<?
$sApplicationSectorList = getList("tbl_application_sectors a, tbl_application_sectors_data ad", "a.id", "ad.name", "a.status='A' AND a.id=ad.application_id AND ad.language_id='{$_SESSION["LanguageId"]}'");
foreach ($sApplicationSectorList as $iApplication => $sApplication)
{
?>
<option value="<?= $iApplication ?>"><?= $sApplication ?></option>
<?
}
?>
</select>
</td>
</tr>
</table>
</div>
<div class="form-filed">
<label for="Comments" class="mktoLabel"><?= $sTranslations["txt-comments"] ?>: </label>
<textarea id="Comments" name="comments" rows="2" class="mktoField" maxlength="2000" ></textarea>
</div>
<div class="form-filed captcha">
<div class="row">
<div class="col-md-4">
<div class="captcha">
<img src="../requires/demo_captcha.php" class="imgcaptcha" alt="captcha" />
<img src="../images/refresh.png" alt="reload" class="refresh" />
</div>
<div class="cap">
<label for="captcha"><?= $sTranslations["captcha"] ?> </label>
</div>
</div>
<div class="col-md-8">
<input placeholder="Enter Captcha code" type="text" name="captcha" id="captcha" value="" class="textbox" required />
</div>
</div>
</div>
<div class="mkt-submit-top">
<input type="submit" class="mkt_submit" name="submit" id="submit" value="Submit">
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
<script language="javascript">
$(document).ready(function(){
$(".refresh").click(function () {
$(".imgcaptcha").attr("src","../requires/demo_captcha.php?_="+((new Date()).getTime()));
});
$(".mkt-submit-top").click(function () {
var captcha = $('#captcha').val();
$.post("../requires/submit_demo_captcha.php?"+$("#mktoForm_1050").serialize(), {"captcha":captcha }, function(response){
if(response==1){
$(".imgcaptcha").attr("src","../requires/demo_captcha.php?_="+((new Date()).getTime()));
// clear_form();
// alert("Data Submitted Successfully.");
window.location.replace("thank-you.html");
}else{
// var tppp = 'abc';
$("#captcha").val('');
alert("wrong captcha code!");
}
});
return false;
});
});
</script>
<?= $sPageContents ?>```