Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Contact Us Configuration


Guest

Recommended Posts

Hello all,

Does anyone know how I can customize the Contact Us form so it will have more fields to fill in?

 

Currently there is:

Full Name:

Email:

Inquiry

 

I need to get these fields asked:

Full Name:

Email Address:

Daytime Phone:

Fax:

Your physical location:

Contemplated shipment destination:

Intended Marketing and Sales Region:

Please provide the description and quantity of each humidor model you're interested in:

Please provide our Humidor model number, or your own specifications:

Please provide any additional comments, notes, or questions:

 

Big thanks in Advance.

Bill

Link to comment
Share on other sites

  • 3 weeks later...

While adding additional fields give the store owner more information to work with, it may also provide a deterrent to customers. The more fields there are, the less likely the customer is going to expend the effort to fill them out. Think carefully about how much you need this information before adding a field for it.

 

That said, here's how I modified contact_us.php for a client. Find the following code near the top of the page:

  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']);
   $enquiry = tep_db_prepare_input($HTTP_POST_VARS['enquiry']);

then change it to this:

  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']);
   $enquiry  = ' Company: ' . tep_db_prepare_input($HTTP_POST_VARS['company']) . "\n";
   $enquiry .= 'Address1: ' . tep_db_prepare_input($HTTP_POST_VARS['address1']) . "\n";
   $enquiry .= 'Address2: ' . tep_db_prepare_input($HTTP_POST_VARS['address2']) . "\n";
   $enquiry .= '    City: ' . tep_db_prepare_input($HTTP_POST_VARS['city']) . "\n";
   $enquiry .= '   State: ' . tep_db_prepare_input($HTTP_POST_VARS['state']) . "\n";
   $enquiry .= '     Zip: ' . tep_db_prepare_input($HTTP_POST_VARS['zip']) . "\n";
   $enquiry .= ' Country: ' . tep_db_prepare_input($HTTP_POST_VARS['country']) . "\n";
   $enquiry .= '   Phone: ' . tep_db_prepare_input($HTTP_POST_VARS['phone']) . "\n\n";
   $enquiry .= ' Message: ' . tep_db_prepare_input($HTTP_POST_VARS['enquiry']);

Now find this code further down the page:

                  <tr>
                   <td class="emailLegend"><?php echo ENTRY_FULL_NAME; ?></td>
                   <td class="main"><?php echo tep_draw_input_field('name') . ' ' . (tep_not_null(ENTRY_FULL_NAME_TEXT) ? '<span class="inputRequirement">' . ENTRY_FULL_NAME_TEXT . '</span>': ''); ?></td>
                 </tr>
                 <tr>
                   <td class="emailLegend"><?php echo ENTRY_EMAIL; ?></td>
                   <td class="main"><?php echo tep_draw_input_field('email') . ' ' . (tep_not_null(ENTRY_EMAIL_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_EMAIL_ADDRESS_TEXT . '</span>': '') ?></td>
                 </tr>
                 <tr>
                   <td colspan=2 class="main"><?php echo ENTRY_ENQUIRY; ?></td>
                 </tr>
                 <tr>
                   <td colspan=2><?php echo tep_draw_textarea_field('enquiry', 'soft', 50, 15); ?></td>
                 </tr>

and replace it with this:

                  <tr>
                   <td class="emailLegend"><?php echo ENTRY_FULL_NAME; ?></td>
                   <td class="main"><?php echo tep_draw_input_field('name') . ' ' . (tep_not_null(ENTRY_FULL_NAME_TEXT) ? '<span class="inputRequirement">' . ENTRY_FULL_NAME_TEXT . '</span>': ''); ?></td>
                 </tr>
                 <tr>
                   <td class="emailLegend"><?php echo ENTRY_EMAIL; ?></td>
                   <td class="main"><?php echo tep_draw_input_field('email') . ' ' . (tep_not_null(ENTRY_EMAIL_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_EMAIL_ADDRESS_TEXT . '</span>': '') ?></td>
                 </tr>
                 <tr>
                   <td class="emailLegend"><?php echo ENTRY_COMPANY; ?></td>
                   <td class="main"><?php echo tep_draw_input_field('company') ?></td>
                 </tr>
                 <tr>
                   <td class="emailLegend"><?php echo ENTRY_ADDRESS_1; ?></td>
                   <td class="main"><?php echo tep_draw_input_field('address1'); ?></td>
                 </tr>
                 <tr>
                   <td class="emailLegend"><?php echo ENTRY_ADDRESS_2; ?></td>
                   <td class="main"><?php echo tep_draw_input_field('address2'); ?></td>
                 </tr>
                 <tr>
                   <td class="emailLegend"><?php echo ENTRY_CITY; ?></td>
                   <td class="main"><?php echo tep_draw_input_field('city'); ?></td>
                 </tr>
                 <tr>
                   <td class="emailLegend"><?php echo ENTRY_STATE; ?></td>
                   <td class="main"><?php echo tep_draw_input_field('state') . ' ' . (tep_not_null(ENTRY_STATE_TEXT_USA) ? '<span class="inputRequirement">' . ENTRY_STATE_TEXT_USA . '</span>': '') ?></td>
                 </tr>
                 <tr>
                   <td class="emailLegend"><?php echo ENTRY_POST_CODE; ?></td>
                   <td class="main"><?php echo tep_draw_input_field('zip'); ?></td>
                 </tr>
                 <tr>
                   <td class="emailLegend"><?php echo ENTRY_COUNTRY; ?></td>
                   <td class="main"><?php echo tep_draw_input_field('country'); ?></td>
                 </tr>
                 <tr>
                   <td class="emailLegend"><?php echo ENTRY_TELEPHONE_NUMBER; ?></td>
                   <td class="main"><?php echo tep_draw_input_field('phone') . ' ' . (tep_not_null(ENTRY_TELEPHONE_NUMBER_TEXT_USA) ? '<span class="inputRequirement">' . ENTRY_TELEPHONE_NUMBER_TEXT_USA . '</span>': '') ?></td>
                 </tr>
                 <tr>
                   <td colspan=2 class="main"><?php echo ENTRY_ENQUIRY; ?></td>
                 </tr>
                 <tr>
                   <td colspan=2><?php echo tep_draw_textarea_field('enquiry', 'soft', 50, 15); ?></td>
                 </tr>

You will also need to define the text constants in the appropriate language file. Change the field names to whatever you want, just remember to keep the same names in the two sections of code.

 

I didn't bother to check any of the new fields for valid entries. Forcing people to fill out all of those additional fields is even more of a deterrent. I did mark a couple of them as required, but it's just social engineering; the form doesn't enforce this.

 

I also added a box with the physical address and telephone numbers to this page, so now all of the contact information is in one place. The result is here.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

I think I may be using a different version. Here is what my top looks like:

 

 

 

$error = false;

if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'send')) {

if (tep_validate_email(trim($HTTP_POST_VARS['email']))) {

tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT, $HTTP_POST_VARS['enquiry'], $HTTP_POST_VARS['name'], $HTTP_POST_VARS['email']);

tep_redirect(tep_href_link(FILENAME_CONTACT_US, 'action=success'));

} else {

$error = true;

}

}

 

$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_CONTACT_US));

?>

Link to comment
Share on other sites

That certainly does look different from my MS2 code. The code that I showed at the top of the page will probably exist, but elsewhere on the page or on a different page that does the processing. I have no idea where that file might be. It could be contact_us_info.php or something similar. Hopefully somebody more familiar with the other versions of the code can help you out.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

  • 2 months later...
  • 2 years later...
I am trying to create a form and clearly I have not done something right here. When the form is submitted the generated email comes up "blank". None of the field spaces are filled appearing. Any advice?

 

http://tekrispower.com/inverters/contact_us2.php

I assume that you are using catalog/contact_us as a template. If so, check that your field names (in the HTML section) match the POST variables in the top part. For example, in the contact form,

				<td class="main"><?php echo tep_draw_input_field('name'); ?></td>

matches up to

	$name = tep_db_prepare_input($HTTP_POST_VARS['name']);

in the top part. If those match, make certain that the variable names match those used in the tep_mail() function.

 

Regards

Jim

 

(Edit: Stupid spell checker.)

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

does anyone know how to make the customer's entered email address and name show up along with the message in the body of the email that I receive?? thanks!

If you are referring to catalog/contact_us.php, find this code (line 21):

	$enquiry = tep_db_prepare_input($HTTP_POST_VARS['enquiry']);

and replace it with this:

	$enquiry  = '	Name: ' . $name . "\n";
$enquiry .= '   Email: ' . $email_address . "\n";
$enquiry .= tep_db_prepare_input($HTTP_POST_VARS['enquiry']);

The changes will be similar for other forms. You don't need to add the quoted labels, but I think they make the message easier to read.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

It all looks like it matches to me:

 

<?php

/*

$Id: contact_us.php,v 1.42 2003/06/12 12:17:07 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

require('includes/application_top.php');

 

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CONTACT_US2);

 

$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']);

$company = tep_db_prepare_input($HTTP_POST_VARS['company']);

$address = tep_db_prepare_input($HTTP_POST_VARS['address']);

$phone = tep_db_prepare_input($HTTP_POST_VARS['phone']);

$model = tep_db_prepare_input($HTTP_POST_VARS['model']);

$warranty = tep_db_prepare_input($HTTP_POST_VARS['warranty']);

$complaint = tep_db_prepare_input($HTTP_POST_VARS['complaint']);

 

 

if (tep_validate_email($email_address)) {

tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT, $complaint, $name, $company, $address, $phone, $model, $warranty, $email_address);

 

tep_redirect(tep_href_link(FILENAME_CONTACT_US2, 'action=success'));

} else {

$error = true;

 

$messageStack->add('contact', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);

}

}

 

$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_CONTACT_US2));

?>

<!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; ?>">

<?php

// BOF: WebMakers.com Changed: Header Tag Controller v2.5.2

// Replaced by header_tags.php

if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) {

require(DIR_WS_INCLUDES . 'header_tags.php');

} else {

?>

<title><?php echo TITLE; ?></title>

<?php

}

// EOF: WebMakers.com Changed: Header Tag Controller v2.5.2

?>

<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">

<link rel="stylesheet" type="text/css" href="stylesheet.css">

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->

 

<!-- body //-->

<table border="0" width="100%" cellspacing="3" cellpadding="3">

<tr>

<td width="170" valign="top"><table border="0" width="170" 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_us2', 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"><?php echo HEADING_TITLE; ?></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><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></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="main" align="center"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_man_on_board.gif', 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" class="infoBox">

<tr class="infoBoxContents">

<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) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</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="0" cellpadding="2">

<tr>

<td class="main"><?php echo ENTRY_NAME; ?></td>

</tr>

<tr>

<td class="main"><?php echo tep_draw_input_field('name'); ?></td>

</tr>

<tr>

<td class="main"><?php echo ENTRY_COMPANY; ?></td>

</tr>

<tr>

<td class="main"><?php echo tep_draw_input_field('company'); ?></td>

</tr>

<tr>

<td class="main"><?php echo ENTRY_EMAIL; ?></td>

</tr>

<tr>

<td class="main"><?php echo tep_draw_input_field('email'); ?></td>

</tr>

<tr>

<td class="main"><?php echo ENTRY_PHONE; ?></td>

</tr>

<tr>

<td class="main"><?php echo tep_draw_input_field('phone'); ?></td>

</tr>

<tr>

<td class="main"><?php echo ENTRY_ADDRESS; ?></td>

</tr>

<tr>

<td><?php echo tep_draw_textarea_field('address', 'soft', 50, 4); ?></td>

</tr>

<tr>

<td class="main"><?php echo ENTRY_MODEL; ?></td>

</tr>

<tr>

<td class="main"><?php echo tep_draw_input_field('model'); ?></td>

</tr>

<tr>

<td class="main"><?php echo ENTRY_WARRANTY; ?></td>

</tr>

<tr>

<td class="main"><?php echo tep_draw_input_field('warranty'); ?></td>

</tr>

<tr>

<td class="main"><?php echo ENTRY_COMPLAINT; ?></td>

</tr>

<tr>

<td><?php echo tep_draw_textarea_field('complaint', 'soft', 50, 15); ?></td>

</tr>

</table></td>

</tr>

</table></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" class="infoBox">

<tr class="infoBoxContents">

<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 tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></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="2">

<!-- 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>

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Link to comment
Share on other sites

Then the problem would apparently be your use of the tep_mail function. Unless you have modified the function (in catalog/includes/functions/general.php), the usage should be:

  function tep_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address)

You probably want to add all of those extra fields to the body of the message anyway. See my answer to monakur above for a way to do that. Then just put the call to tep_mail back the way it was and you should be set.

 

If you have modified the tep_mail function itself, then please post your modified version so that I can take a look at it.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Then the problem would apparently be your use of the tep_mail function. Unless you have modified the function (in catalog/includes/functions/general.php), the usage should be:

  function tep_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address)

You probably want to add all of those extra fields to the body of the message anyway. See my answer to monakur above for a way to do that. Then just put the call to tep_mail back the way it was and you should be set.

 

If you have modified the tep_mail function itself, then please post your modified version so that I can take a look at it.

 

Regards

Jim

 

 

I have not changed the tep_mail function at all. I had also tried using the form with this:

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']);

$enquiry = ' Company: ' . tep_db_prepare_input($HTTP_POST_VARS['company']) . "\n";

$enquiry .= 'Complete Address: ' . tep_db_prepare_input($HTTP_POST_VARS['address1']) . "\n";

$enquiry .= 'Phone Number: ' . tep_db_prepare_input($HTTP_POST_VARS['phone']) . "\n";

$enquiry .= 'Model Number: ' . tep_db_prepare_input($HTTP_POST_VARS['model']) . "\n";

$enquiry .= 'Under Warranty: ' . tep_db_prepare_input($HTTP_POST_VARS['warranty']) . "\n";

$enquiry .= ' Complaint: ' . tep_db_prepare_input($HTTP_POST_VARS['complaint']) . "\n";

 

and that also came out as a blank email

 

I tried this:

 

$enquiry = ' Name: ' . $name . "\n";

$enquiry .= ' Email: ' . $email_address . "\n";

$enquiry = ' Address: ' . $address . "\n";

$enquiry .= ' Phone ' . $phone . "\n";

$enquiry = ' Model: ' . $model . "\n";

$enquiry = ' Warranty: ' . $warranty . "\n";

$enquiry .= ' Email: ' . $email_address . "\n";

$enquiry .= tep_db_prepare_input($HTTP_POST_VARS['complaint']);

 

also came back as a blank email..........

Link to comment
Share on other sites

anyone? I'm really at a loss here :(

Could you please post the top part of your code? The part before the HTML starts, that is.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...