Forums / Basic Configuration / Add a field to the contast us form

Add a field to the contast us form

Locked

Views: 3,107

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
2 Aug 2006, 4:55 PM
#1
kadesign avatar

kadesign

Totally Zenned

Join Date:
Feb 2005
Location:
New Jersey
Posts:
593
Plugin Contributions:
0

Add a field to the contast us form

I apologize in advance if this has been asked and answered...I have the latest version of Zen, 1.3.0.2, I would like to add a field for the customer to include their phone number in the contact us form. Is this possible, and if so, can anyone explain how to go about doing so? I don't want this to be required as it is only for people who wish to book shows.

Thanks in advance,
Kelly

Kelly Ann
Raven Media, LLC

2 Aug 2006, 5:14 PM
#2
kadesign avatar

kadesign

Totally Zenned

Join Date:
Feb 2005
Location:
New Jersey
Posts:
593
Plugin Contributions:
0

Re: Add a field to the contast us form

BTW I did get some search results for my question, but they are for older versions.

Kelly Ann
Raven Media, LLC

2 Aug 2006, 5:20 PM
#3
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Add a field to the contast us form

Since this is about template customizing + for Zen-Cart v1.3x (and, correct, results are only found for older versions only) - sounds like fun. :wink2:

// Step 1:

In your includes/templates/<your_template>/tpl_contact_us_default.php file,

find:

<label class="inputLabel" for="email-address"><?php echo ENTRY_EMAIL; ?></label>
<?php echo zen_draw_input_field('email', ($error ? $_POST['email'] : $email), ' size="40" id="email-address"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />

add below:

<label class="inputLabel" for="contactphonenumber"><?php echo ENTRY_TELEPHONE_NUMBER; ?></label>
<?php echo zen_draw_input_field('phone_number', $phone_number, ' size="40" id="phone_number"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />

// Step 2:

In your includes/modules/pages/contact_us/<your_template>/header_php.php file,

find:

$enquiry = zen_db_prepare_input(strip_tags($_POST['enquiry']));

add below:

$phone_number = zen_db_prepare_input(stripslashes(trim($_POST['phone_number']))) : "";

Then, find:

if ($zc_validate_email and !empty($enquiry) and !empty($name)) {

replace with:

if ($zc_validate_email and !empty($enquiry) and !empty($name) and !empty($phone_number)) {

Then, find:

$html_msg['EXTRA_INFO'] = $extra_info['HTML'];

add right below:

$html_msg['PHONE_NUMBER'] = $phone_number;

Then, find:

if (empty($enquiry)) {
      $messageStack->add('contact', ENTRY_EMAIL_CONTENT_CHECK_ERROR);
    }

add right below:

if (empty($phone_number)) {
$messageStack->add('contact', ENTRY_EMAIL_PHONE_NUMBER_CHECK_ERROR);
}

// Step 3:

In your includes/languages/english/<your_language>/contact_us.php file,

add the following entries in:

define ('ENTRY_TELEPHONE_NUMBER', 'Contact phone number:');
define('ENTRY_EMAIL_PHONE_NUMBER_CHECK_ERROR', 'You did not filled out your contact phone number.');

// Step 4:

In your email/email_template_contact_us.html file,

find:

$EXTRA_INFO

add below:

$PHONE_NUMBER

Of course, the email template modifications part is only suggested - you can add this variable anywhere you'd like, from that template file, in order to fit your needs. :wink2:

I believe these should be all. :cool:

2 Aug 2006, 5:36 PM
#4
kadesign avatar

kadesign

Totally Zenned

Join Date:
Feb 2005
Location:
New Jersey
Posts:
593
Plugin Contributions:
0

Re: Add a field to the contast us form

Wow! Thanks for the reply. Let me grab a cup of tea and settle in for a bit! This could take a little while. :smile:

Thank you again! :D

Kelly Ann
Raven Media, LLC

2 Aug 2006, 5:43 PM
#5
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Add a field to the contast us form

Very well. Please advise if it works (even if it doesn't :lookaroun). :smile:

3 Aug 2006, 6:34 AM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Add a field to the contast us form

A couple corrections to TheOracle's post...

  1. Label mismatch:
<label class="inputLabel" for="contactphonenumber"><?php echo ENTRY_TELEPHONE_NUMBER; ?></label>
<?php echo zen_draw_input_field('phone_number', $phone_number, ' size="40" id="phone_number"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" /> 
```should be:```php
<label class="inputLabel" for="phone-number"><?php echo ENTRY_TELEPHONE_NUMBER; ?></label>
<?php echo zen_draw_input_field('phone_number', $phone_number, ' size="40" id="phone-number"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" /> 
  1. Syntax error:
$phone_number = zen_db_prepare_input(stripslashes(trim($_POST['phone_number']))) : ""; 
```should be:```php
$phone_number = (isset($_POST['phone_number'])) ? zen_db_prepare_input($_POST['phone_number']) : '';
```(FYI: trim and stripslashes are already done by the prepare-input function)


3. You said you didn't want the phone number to be "required", so don't make this change:```php
if ($zc_validate_email and !empty($enquiry) and !empty($name) and !empty($phone_number)) {  
  1. And of course change the text in the new define() to suit your use.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

3 Aug 2006, 12:38 PM
#7
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Add a field to the contast us form

:shocking: :shocking: :shocking:

Ok ... this one really hurts. I have something in my eye ... :cry:

FYI: trim and stripslashes are already done by the prepare-input function)

Thanks. I wasn't aware it was included.

4 Sep 2006, 6:31 AM
#8
samad64 avatar

samad64

Totally Zenned

Join Date:
May 2006
Location:
Texas
Posts:
554
Plugin Contributions:
2

Re: Add a field to the contast us form

sleepless, did you get this to work? For some reason everything seems to look good on mine, but I still don't receive the information I added. Basically, I added a line that asks for the product's name and it is not required. I tested it on my test site, and though it appears to be a functional form.. I never see it in my text-based e-mails.

Also, when I turn on the HTML emails, where it should show a small field of products that the customer is interested in, it shows $ITEM_NAME (the variable i'm using). Any ideas?

28 Dec 2008, 1:14 PM
#9
rainmist avatar

rainmist

New Zenner

Join Date:
Jun 2007
Posts:
71
Plugin Contributions:
0

Re: Add a field to the contast us form

Does the codes work or not?

LED flood Lights - Energy saving! Eco-friendly! Long lifespan.
Bollard Lights - Excelllent design.