No Captcha num formulário de contato
Olá, eu usei este tutorial pra implementar no meu formulário de contato:
Eu acredito que consegui fazer todas as partes, menos esta:
<?php
if ($response != null && $response->success) {
echo "Olá, " . $_POST["name"] . " (" . $_POST["email"] . "), obrigado por enviar seu formulário!";
} else {
?>
no meu formulário, as vezes ele some inteiro e as vezes ele vai direto pra mensagem de sucesso dependo onde eu coloco.
<?php
require('includes/application_top.php');
// busca a biblioteca recaptcha
require_once "recaptchalib.php";
// CUR start
$account_query = tep_db_query("select customers_firstname, customers_telephone,customers_lastname, customers_email_address,customers_id from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
$account = tep_db_fetch_array($account_query);
$name = $account['customers_firstname']." ".$account['customers_lastname'] ;
$customers_telephone = $account['customers_telephone'] ;
$email_address = $account['customers_email_address'] ;
// CUR end
// campos extras telefone e ip
$phone = $account['customers_telephone'] ;
$customer_id = $account['customers_id'] ;
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CONTACT_US);
$error = false;
if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'send')) {
$name = tep_db_prepare_input($HTTP_POST_VARS['name']);
$email_address = tep_db_prepare_input($HTTP_POST_VARS['email']);
// campos extras telefone e ip
$xipaddress = $HTTP_SERVER_VARS["REMOTE_ADDR"];
$phone = tep_db_prepare_input($HTTP_POST_VARS['phone']);// campos extras telefone e ip
$enquiry = tep_db_prepare_input($HTTP_POST_VARS['enquiry']);
if (tep_validate_email($email_address)) {
// campos extras telefone e ip email cópia
$enquiryx = '##### Fale Conosco - Apopular #####' ."\n\n" . 'Mensagem de: ' . $name . "\n" . 'Email: ' . $email_address . "\n" . 'Telefone: ' . $phone . "\n" . 'Cliente numero: ' . $customer_id . "\n" . 'IP: ' . $xipaddress . ' ' . "\n\n" . 'Mensagem:' . "\n" . $enquiry;
// campos extras telefone e ip
// tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, 'Fale conosco Apopular', $enquiry, $name, $email_address);
define('EMAIL_SUBJECT_3','Fale Conosco Apopular');
// campos adicionais telefone e ip
tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT_3, $enquiryx, $name, $email_address);
// telefone e ip
tep_redirect(tep_href_link(FILENAME_CONTACT_US, 'action=success'));
} else {
$error = true;
$messageStack->add('contact', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
}
}
$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_CONTACT_US));
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title>Fale conosco - <?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<meta name="Description" content="Preencha seus dados e faça a sua pergunta ou deixe sua mensagem que logo, logo responderemos, use o fale conosco é fácil. ">
<meta name="Keywords" content="fale conosco, entre em contato, deixe a sua mensagem, dúvida">
<link rel="canonical" href="http://<?php echo $_SERVER['HTTP_HOST']; ?><?php echo parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ); ?>" />
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<script src='https://www.google.com/recaptcha/api.js'></script>
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
<tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"><!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
<!-- body_text //-->
<td width="100%" valign="top"><?php echo tep_draw_form('contact_us', tep_href_link(FILENAME_CONTACT_US, 'action=send')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="pageHeading"><h1>Fale com Apopular</h1></td>
<td class="pageHeading" align="right"><?php //echo tep_image(DIR_WS_IMAGES . 'table_background_contact_us.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
</tr>
</table></td>
</tr>
<tr>
<td class="categoria">
<!-- Holiday Settings Begin -->
<?php
if (HOLIDAY_SETTINGS == 'on'){
?>
<img src="../images/warning.png" width="20" height="20" />
<b>NOTA:</b> <?php echo HOLIDAY_MESSAGE ;?>
<br /><br /><?php
}
?><!-- Holiday Settings End -->
</td>
</tr>
<?php
if ($messageStack->size('contact') > 0) {
?>
<tr>
<td><?php echo $messageStack->output('contact'); ?></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>
<?php
}
if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'success')) {
?>
<tr>
<td class="categoria" align="center">
<?php echo tep_image(DIR_WS_IMAGES . 'sinal_joia.jpg', HEADING_TITLE, '0', '0', 'align="left"') . TEXT_SUCCESS;
?></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>
<tr>
<td><table border="0" width="100%" cellspacing="1" cellpadding="2" >
<tr >
<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
<td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '" class="butBlue">Continuar</a>'; ?></td>
<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<?php
} else {
?>
<tr>
<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
<tr class="infoBoxContents">
<td><table border="0" width="100%" cellspacing="5" cellpadding="5">
<tr>
<td class="categoria" width="5%" >Nome:</td>
<td width="25%" ><input name="name" type="text" id="name" size="30" obrigatorio="1" class="InputBorda" required><span class="inputRequirement"> *</span></td>
<td width="50%" rowspan="3" class="categoria"><h5><a href="corporativo.php" target="_self">Atendimento corporativo: <u>Clique aqui</u></a>.</h5><h5>Orçamento: <a href="mailto:contato@apopular.com.br"><u>contato@apopular.com.br</u></a></h5></td>
</tr>
<tr>
<td width="5%" class="categoria" >Email: </td>
<td width="25%"><input name="email" type="email" id="email" size="30" obrigatorio="1" class="InputBorda" required><span class="inputRequirement"> *</span></td>
</tr>
<tr>
<td width="5%" class="categoria" >Telefone: </td>
<td width="25%" ><input name="phone" type="text" id="phone" size="30" obrigatorio="1" class="InputBorda"><span class="inputRequirement"> Opcional</span></td>
</tr>
<tr>
<td colspan="3" class="categoria" ><?php echo ENTRY_ENQUIRY; ?></td>
</tr>
<tr>
<td colspan="3"><table width="50%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><?php //echo tep_draw_textarea_field('enquiry', 'soft',2,6); ?>
<!--<textarea name="mensagem" cols="40" rows="3" id="mensagem" class="InputBorda" required></textarea>-->
<textarea name="enquiry" cols="40" rows="3" class="InputBorda" maxlength="2000" wrap="soft" required></textarea></td>
</tr>
</table>
</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td>
<?php
// se submetido, verifique a resposta
if ($_POST["g-recaptcha-response"]) {
$response = $reCaptcha->verifyResponse(
$_SERVER["REMOTE_ADDR"],
$_POST["g-recaptcha-response"]
);
}
?>
<div class="g-recaptcha" data-sitekey="6LeopAcTAAAAAKnMlIazNJQD0cG8vI9HuX_3OX80"></div>
</td>
</tr>
<tr>
<td><table border="0" width="100%" cellspacing="1" cellpadding="2" >
<tr >
<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td align="left" width="70%"><?php
//echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?>
<input type="submit" class="butBlue" value="Enviar"></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<?php
}
?>
</table></form></td>
<!-- body_text_eof //-->
<!-- <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="0">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //
</table></td>-->
</tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
<!--<iframe src="https://www.tomticket.com/helpdesk?id=EP07407" style="width:100%; height:100%;"></iframe>-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
As partes com espaçamento grande é onde eu estou tentando colocar.
Valeu a quem puder indicar,
Marcelo
Discussão (2)
Carregando comentários...