Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

contact and tell a friend form aren't working anymore?


mystique71

Recommended Posts

Hi Guys, I am so sorry to bother you again but oscommerce is really driving me crazy and please don't mention the bootstrap again I am sure I am not the only one who is still working with the normal oscommerce, bootstrap will come later when I find peace in my life :(

 

the problem I have now is that suddenly the contact and tell a friend form ain't working anymore just like that. a couple of days ago it worked just fine and today when i checked, and filled out the forms to test, it directs me to the form fields again??? anyone please help me with this???

 

 

http://www.uniquegiftcreations.nl/webwinkel/contact_us.php

 

http://www.uniquegiftcreations.nl/webwinkel/tell_a_friend.php?products_id=57

Link to comment
Share on other sites

@@mystique71 this is the same error which you had on product_info.php $request_type paramater should be add into the tep_draw_form() function.

:blink:
osCommerce based shop owner with minimal design and focused on background works. When the less is more.
Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store.

Link to comment
Share on other sites

Hi Gergely  uuh so what code and where do I need to insert into the contact and tell a friend page?

 

this is my contact us:

 

<?php
/*
  $Id$
 
  osCommerce, Open Source E-Commerce Solutions
 
  Copyright © 2010 osCommerce
 
  Released under the GNU General Public License
*/
 
  require('includes/application_top.php');
// clean posted vars
reset($_POST);
 while (list($key, $value) = each($_POST)) {
  if (!is_array($_POST[$key])) {
 $_POST[$key] = preg_replace("/[^ a-zA-Z0-9@%:{}_.-]/i", "", urldecode($_POST[$key]));
    } else { unset($_POST[$key]); } // no arrays expected 
 }
 
  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CONTACT_US);
 
  if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'send') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) {
    $error = false;
 
    $name = tep_db_prepare_input($HTTP_POST_VARS['name']);
    $email_address = tep_db_prepare_input($HTTP_POST_VARS['email']);
    $enquiry = tep_db_prepare_input($HTTP_POST_VARS['enquiry']);
// BOF MATH SECURITY
$protect = tep_db_prepare_input($HTTP_POST_VARS['protect']);
$lock = tep_db_prepare_input(base64_decode($HTTP_POST_VARS['lock'])); 
 
if ($protect != $lock) {
  $error = true;
 
  $messageStack->add('contact', ENTRY_EMAIL_HUMAN_CHECK_ERROR);
}
// EOF MATH SECURITY
    if (!tep_validate_email($email_address)) {
      $error = true;
 
      $messageStack->add('contact', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
    }
 
    $actionRecorder = new actionRecorder('ar_contact_us', (tep_session_is_registered('customer_id') ? $customer_id : null), $name);
    if (!$actionRecorder->canPerform()) {
      $error = true;
 
      $actionRecorder->record(false);
 
      $messageStack->add('contact', sprintf(ERROR_ACTION_RECORDER, (defined('MODULE_ACTION_RECORDER_CONTACT_US_EMAIL_MINUTES') ? (int)MODULE_ACTION_RECORDER_CONTACT_US_EMAIL_MINUTES : 15)));
    }
 
    if ($error == false) {
      tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT, $enquiry, $name, $email_address);
 
      $actionRecorder->record();
 
      tep_redirect(tep_href_link(FILENAME_CONTACT_US, 'action=success'));
    }
  }
 
  $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_CONTACT_US));
 
  require(DIR_WS_INCLUDES . 'template_top.php');
?>
 
<h1><?php echo HEADING_TITLE; ?></h1>
 
<?php
  if ($messageStack->size('contact') > 0) {
    echo $messageStack->output('contact');
  }
 
  if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'success')) {
?>
 
<div class="contentContainer">
  <div class="contentText">
    <?php echo TEXT_SUCCESS; ?>
  </div>
 
  <div style="float: right;">
    <?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', tep_href_link(FILENAME_DEFAULT)); ?>
  </div>
</div>
 
<?php
  } else {
?>
 
<?php echo tep_draw_form('contact_us', tep_href_link(FILENAME_CONTACT_US, 'action=send'), 'post', '', true); ?>
<!-- BOF MATH SECURITY //-->
<?php
$a = rand(1, 9);
$b = rand(1, 9);
echo tep_draw_hidden_field('lock', base64_encode(($a + $ B)));
?>
<!-- EOF MATH SECURITY //-->
<div class="contentContainer">
  <div class="contentText">
    <table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td class="fieldKey"><?php echo ENTRY_NAME; ?></td>
        <td class="fieldValue"><?php echo tep_draw_input_field('name'); ?></td>
      </tr>
      <tr>
        <td class="fieldKey"><?php echo ENTRY_EMAIL; ?></td>
        <td class="fieldValue"><?php echo tep_draw_input_field('email'); ?></td>
      </tr>
      <tr>
        <td class="fieldKey" valign="top"><?php echo ENTRY_ENQUIRY; ?></td>
        <td class="fieldValue"><?php echo tep_draw_textarea_field('enquiry', 'soft', 50, 15); ?></td>
      </tr>
    </table>
  </div>
<!-- BOF MATH SECURITY //-->
<div class="form-group has-feedback">
      <label for="inputHuman" class="control-label col-sm-3"><?php echo sprintf(ENTRY_HUMAN, $a, $ B); ?></label>
      <div class="col-sm-9">
        <?php
echo tep_draw_input_field('protect', NULL, 'required autofocus="autofocus" aria-required="true" id="inputHuman" placeholder="' . sprintf(ENTRY_HUMAN, $a, $ B) . '"');
        echo FORM_REQUIRED_INFORMATION; ?>
      </div>
    </div>
<!-- EOF MATH SECURITY //-->
  <div class="buttonSet">
    <span class="buttonAction"><?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', null, 'primary'); ?></span>
  </div>
</div>
 
</form>
 
<?php
  }
 
  require(DIR_WS_INCLUDES . 'template_bottom.php');
  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
 
 
and this my tell a friend:
 
<?php
/*
  $Id$
 
  osCommerce, Open Source E-Commerce Solutions
 
  Copyright © 2010 osCommerce
 
  Released under the GNU General Public License
*/
 
  require('includes/application_top.php');
 
  if (!tep_session_is_registered('customer_id') && (ALLOW_GUEST_TO_TELL_A_FRIEND == 'false')) {
    $navigation->set_snapshot();
    tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
  }
  if (tep_session_is_registered('customer_id')) {
    $account_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
    if (tep_db_num_rows($account_query) != 1 ) tep_redirect(tep_href_link(FILENAME_LOGOFF, '', 'SSL')); // invalid customer id
    $account = tep_db_fetch_array($account_query);
 
    $from_name = $account['customers_firstname'] . ' ' . $account['customers_lastname'];
    $from_email_address = $account['customers_email_address'];
  }
 
  $valid_product = false;
  if (isset($HTTP_GET_VARS['products_id'])) {
    $product_info_query = tep_db_query("select pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");
    if (tep_db_num_rows($product_info_query)) {
      $valid_product = true;
 
      $product_info = tep_db_fetch_array($product_info_query);
    }
  }
 
  if ($valid_product == false) {
    tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . (int)$HTTP_GET_VARS['products_id']));
  }
 
  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_TELL_A_FRIEND);
 
  if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) {
    $error = false;
 
    $to_email_address = tep_db_prepare_input($HTTP_POST_VARS['to_email_address']);
    $to_name = tep_db_prepare_input($HTTP_POST_VARS['to_name']);
    if (!tep_session_is_registered('customer_id')) {
      $from_email_address = tep_db_prepare_input($HTTP_POST_VARS['from_email_address']);
      $from_name = tep_db_prepare_input($HTTP_POST_VARS['from_name']);
    }
    $message = tep_db_prepare_input($HTTP_POST_VARS['message']);
 
    // check for attempt to send email from another page besides this sites Tell A Friend script
    if (substr($_SERVER['HTTP_REFERER'], 0, strpos($_SERVER['HTTP_REFERER'], '.php') + 4) != tep_href_link(FILENAME_TELL_A_FRIEND)) {
      if (tep_session_is_registered('customer_id')) {
        $cid = $customer_id;
      } else {
        $cid = TEXT_SPAM_NO_ID;
      }
      $spammsg = sprintf(TEXT_SPAM_MESSAGE, date('l F j, Y  H:i:s'), $cid, $from_name, $from_email_address, tep_db_prepare_input($HTTP_POST_VARS['from_name']), tep_db_prepare_input($HTTP_POST_VARS['from_email_address']), $_SERVER['HTTP_REFERER'], tep_get_ip_address(), $_SERVER['REMOTE_PORT'], $_SERVER['HTTP_USER_AGENT']) . $message;
      tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, TEXT_SPAM_SUBJECT, $spammsg, $from_name, $from_email_address);
      foreach ($_SESSION as $key => $value) unset($_SESSION[$key]);
      echo ERROR_SPAM_BLOCKED;
      tep_exit();
    }
 
    if (empty($from_name)) {
      $error = true;
 
      $messageStack->add('friend', ERROR_FROM_NAME);
    }
 
    if (!tep_validate_email($from_email_address)) {
      $error = true;
 
      $messageStack->add('friend', ERROR_FROM_ADDRESS);
    }
 
    if (empty($to_name)) {
      $error = true;
 
      $messageStack->add('friend', ERROR_TO_NAME);
    }
 
    if (!tep_validate_email($to_email_address)) {
      $error = true;
 
      $messageStack->add('friend', ERROR_TO_ADDRESS);
    }
    
    // check for links to other web sites, a sign that a spammer is trying to use this site to send spam
    $protocols = array('http://', 'https://' 'file://', 'ftp://' 'news://' 'mailto:', 'telnet://', 'ssh:');
    $check = strtolower($message);
    $thisdomain = HTTP_SERVER;
    $thisdomain = strtolower(substr($thisdomain, strpos($thisdomain, '://') + 3));
    foreach ($protocols as $p ) {
      $x = 0;
      while (strpos($check, $p, $x) !== false) {
        $x = strpos($check, $p, $x) + strlen($p);
        if ((substr($check, $x, strlen($thisdomain)) != $thisdomain) || !preg_match('/\/|\s/', substr($check, $x + strlen($thisdomain), 1))) {
          $error = true;
          $messageStack->add('friend', ERROR_INVALID_LINK);
        }
      }
    }
 
    $actionRecorder = new actionRecorder('ar_tell_a_friend', (tep_session_is_registered('customer_id') ? $customer_id : null), $from_name);
    if (!$actionRecorder->canPerform()) {
      $error = true;
 
      $actionRecorder->record(false);
 
      $messageStack->add('friend', sprintf(ERROR_ACTION_RECORDER, (defined('MODULE_ACTION_RECORDER_TELL_A_FRIEND_EMAIL_MINUTES') ? (int)MODULE_ACTION_RECORDER_TELL_A_FRIEND_EMAIL_MINUTES : 15)));
    }
 
    if ($error == false) {
      $email_subject = sprintf(TEXT_EMAIL_SUBJECT, $from_name, STORE_NAME);
      $email_body = sprintf(TEXT_EMAIL_INTRO, $to_name, $from_name, $product_info['products_name'], STORE_NAME) . "\n\n";
 
      if (tep_not_null($message)) {
        $email_body .= $message . "\n\n";
      }
 
      $email_body .= sprintf(TEXT_EMAIL_LINK, tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . (int)$HTTP_GET_VARS['products_id'], 'NONSSL', false)) . "\n\n" .
                     sprintf(TEXT_EMAIL_SIGNATURE, STORE_NAME . "\n" . HTTP_SERVER . DIR_WS_CATALOG . "\n");
 
      tep_mail($to_name, $to_email_address, $email_subject, $email_body, $from_name, $from_email_address);
 
      $actionRecorder->record();
 
      $messageStack->add_session('header', sprintf(TEXT_EMAIL_SUCCESSFUL_SENT, $product_info['products_name'], tep_output_string_protected($to_name)), 'success');
 
      tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . (int)$HTTP_GET_VARS['products_id']));
    }
  } elseif (tep_session_is_registered('customer_id')) {
    $account_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
    $account = tep_db_fetch_array($account_query);
 
    $from_name = $account['customers_firstname'] . ' ' . $account['customers_lastname'];
    $from_email_address = $account['customers_email_address'];
  }
 
  $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_TELL_A_FRIEND, 'products_id=' . (int)$HTTP_GET_VARS['products_id']));
 
  require(DIR_WS_INCLUDES . 'template_top.php');
?>
 
<h1><?php echo sprintf(HEADING_TITLE, $product_info['products_name']); ?></h1>
 
<?php
  if ($messageStack->size('friend') > 0) {
    echo $messageStack->output('friend');
  }
?>
 
<?php echo tep_draw_form('email_friend', tep_href_link(FILENAME_TELL_A_FRIEND, 'action=process&products_id=' . (int)$HTTP_GET_VARS['products_id']), 'post', '', true); ?>
 
<div class="contentContainer">
  <div>
    <span class="inputRequirement" style="float: right;"><?php echo FORM_REQUIRED_INFORMATION; ?></span>
    <h2><?php echo FORM_TITLE_CUSTOMER_DETAILS; ?></h2>
  </div>
<?php
if (tep_session_is_registered('customer_id')) {
?>  
  <div class="contentText">
    <table border="0" cellspacing="2" cellpadding="2" width="100%">
      <tr>
        <td class="fieldKey"><?php echo FORM_FIELD_CUSTOMER_NAME; ?></td>
        <td class="fieldValue"><?php echo $from_name . tep_draw_hidden_field('from_name', $from_name); ?></td>
      </tr>
      <tr>
        <td class="fieldKey"><?php echo FORM_FIELD_CUSTOMER_EMAIL; ?></td>
        <td class="fieldValue"><?php echo $from_email_address . tep_draw_hidden_field('from_email_address', $from_email_address); ?></td>
      </tr>
    </table>
  </div>
<?php  
} else {
?>
  <div class="contentText">
    <table border="0" cellspacing="2" cellpadding="2" width="100%">
      <tr>
        <td class="fieldKey"><?php echo FORM_FIELD_CUSTOMER_NAME; ?></td>
        <td class="fieldValue"><?php echo tep_draw_input_field('from_name', $from_name); ?></td>
      </tr>
      <tr>
        <td class="fieldKey"><?php echo FORM_FIELD_CUSTOMER_EMAIL; ?></td>
        <td class="fieldValue"><?php echo tep_draw_input_field('from_email_address', $from_email_address); ?></td>
      </tr>
    </table>
  </div>
<?php } ?>
 
  <h2><?php echo FORM_TITLE_FRIEND_DETAILS; ?></h2>
 
  <div class="contentText">
    <table border="0" cellspacing="2" cellpadding="2" width="100%">
      <tr>
        <td class="fieldKey"><?php echo FORM_FIELD_FRIEND_NAME; ?></td>
        <td class="fieldValue"><?php echo tep_draw_input_field('to_name') . ' <span class="inputRequirement">' . ENTRY_FIRST_NAME_TEXT . '</span>'; ?></td>
      </tr>
      <tr>
        <td class="fieldKey"><?php echo FORM_FIELD_FRIEND_EMAIL; ?></td>
        <td class="fieldValue"><?php echo tep_draw_input_field('to_email_address') . ' <span class="inputRequirement">' . ENTRY_EMAIL_ADDRESS_TEXT . '</span>'; ?></td>
      </tr>
    </table>
  </div>
 
  <h2><?php echo FORM_TITLE_FRIEND_MESSAGE; ?></h2>
 
  <div class="contentText">
    <table border="0" cellspacing="2" cellpadding="2" width="100%">
      <tr>
        <td class="fieldValue"><?php echo tep_draw_textarea_field('message', 'soft', 40, 8); ?></td>
      </tr>
    </table>
  </div>
 
  <div class="buttonSet">
    <span class="buttonAction"><?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', null, 'primary'); ?></span>
 
    <?php echo tep_draw_button(IMAGE_BUTTON_BACK, 'triangle-1-w', tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . (int)$HTTP_GET_VARS['products_id'])); ?>
  </div>
</div>
 
</form>
 
<?php
  require(DIR_WS_INCLUDES . 'template_bottom.php');
  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
 
Link to comment
Share on other sites

well I changed this line:

 

<?php echo tep_draw_form('contact_us', tep_href_link(FILENAME_CONTACT_US, 'action=send'), 'post', '', true); ?>

 

to this

 

<?php echo tep_draw_form('contact_us', tep_href_link(FILENAME_CONTACT_US, 'action=send', $request_type), 'post', true); ?>

 

and it's still not working??

Link to comment
Share on other sites

What happens if you replace your complete file with a standard non altered file from either a backup copy or from an original file set of what ever version you are using.

REMEMBER BACKUP, BACKUP AND BACKUP

Link to comment
Share on other sites

Many thanks if you post here program codes than use the forum post editor tool bar <> button.  We are not be able to read posted codes.

 

You have non-valid html pages. You have enabled print out php errors before headers. Its good for testing but sometimes it will cause page breaks.
 

<?php echo tep_draw_form('contact_us', tep_href_link(FILENAME_CONTACT_US, 'action=send', $request_type), 'post', '', true); ?>

pls disable ht_cookie_law.php from header tags modules or add full english language file sets correctly to your site.

:blink:
osCommerce based shop owner with minimal design and focused on background works. When the less is more.
Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store.

Link to comment
Share on other sites

I am getting totally confused and I am about to cry at the moment. I thought cookie law was required for a webshop? so If I disable it the forms should be working again? or is this another error?? and how do I solve my form problems I still don't understand?

Link to comment
Share on other sites

oohh Gergely you are my hero again the contact form is working again BIG THANK YOU but what I am doing wrong in the tell a friend page 

<?php echo tep_draw_form('email_friend', tep_href_link(FILENAME_TELL_A_FRIEND, 'action=process&products_id=' . (int)$HTTP_GET_VARS['products_id']), $request_type, 'post', 'SSL', true); ?>
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...