Forums / General Questions / How to pre-populate hidden field in php email form?

How to pre-populate hidden field in php email form?

Views: 1,653

Results 1 to 4 of 4
18 Nov 2013, 12:18 AM
#1
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

How to pre-populate hidden field in php email form?

One one of my clients shops the checkout success page requires the customer to provide additional details. The form is completed by the customer and then emailed to my client. This form needs to contain the order id relating to the just completed order.

I can display that order id with the variable $special_orders_id ($special_orders_id = $zv_orders_id;)

As it stands, the customer needs to enter the $special_order_number again. To avoid entering that id again, I want to make it a pre-populated hidden field which is then automatically added to the email.

Here is the current form (or part thereof...) which is a modified band_signup plugin:

<?php echo zen_draw_form('special_order', zen_href_link(FILENAME_SPECIAL_ORDER, 'action=send')); ?> <div id="specialOrderContent" class="content"> <fieldset id="specialOrder-Info"> <legend>Order Details</legend> <div class="alert forward"><?php echo FORM_REQUIRED_INFORMATION; ?></div> <br class="clearBoth" /> <div id="checkoutSuccessOrderNumber"><?php echo TEXT_YOUR_ORDER_NUMBER . **$special_orders_id**; ?></div> <label class="inputLabel" for="special_order_number">Please enter your Order Number:</label> <?php echo zen_draw_input_field('**special_order_number**', zen_output_string_protected(**$special_order_number**), ' size="30" id="**special_order_number**"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?> <br class="clearBoth" /> </fieldset><br />

[next fieldset - to be completed by customer]
[next fieldset - to be completed by customer]

<div class="buttonRow forward"><?php echo zen_image_submit(BUTTON_IMAGE_SEND, BUTTON_SEND_ALT); ?></div> <div class="buttonRow back"><?php echo zen_back_link() . zen_image_button(BUTTON_IMAGE_BACK, BUTTON_BACK_ALT) . '</a>'; ?></div> <br class="clearBoth" /> </div> </form>

and further down

//assemble the email contents: (the modified code)

  $email_text = 'Additional Order Details: ' . "\n" . 
'------------------------------------------------------' . "\n" . 
    'Special Order Number:' . "\t" . **$special_order_number** . "\n" . 
    'cPanel URL:' . "\t" . $cPanel_URL . "\n" . 
    'cPanel User:' . "\t" . $cPanel_user . "\n" . 
    'cPanel Password:' . "\t" . $cPanel_pwd . "\n" . 
    'Admin URL:' . "\t" . $admin_URL . "\n" . 
    'Admin User:' . "\t" . $admin_user . "\n" . 
    'Admin Password:' . "\t" . $admin_pwd . "\n" . 
    'FTP URL:' . "\t" . $ftp_URL . "\n" . 
    'FTP User:' . "\t" . $ftp_user . "\n" . 
    'FTP Password:' . "\t" . $ftp_pwd . "\n" . 
    'Comments:' . "\t" . $comments . "\n\n" . 
    '------------------------------------------------------' . "\n" .

etc etc

Any hints how to achieve this please?

Thanks / Frank

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

18 Nov 2013, 2:41 AM
#2
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: How to pre-populate hidden field in php email form?

Worked it out - too simple :blush: :

<fieldset id="specialOrder-Info"> <legend>Order Details</legend> <div class="alert forward"><?php echo FORM_REQUIRED_INFORMATION; ?></div> <br class="clearBoth" /> <div id="checkoutSuccessOrderNumber"> <?php echo TEXT_YOUR_ORDER_NUMBER . $special_orders_id; $special_order_number = $special_orders_id; ?> </div> <label class="inputLabel" for="special_order_number">Please enter your Order Number:</label> <?php echo zen_draw_input_field('special_order_number', zen_output_string_protected($special_order_number), ' size="30" id="special_order_number"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?> <br class="clearBoth" /> </fieldset><br />

$special_order_number is now pre-populated but can be changed to any other number

Just need to make it hidden...

Thanks / Frank

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

18 Nov 2013, 4:59 AM
#3
davewest avatar

davewest

Totally Zenned

Join Date:
Dec 2007
Location:
Payson, AZ
Posts:
1,075
Plugin Contributions:
7

Re: How to pre-populate hidden field in php email form?

frank18:

Worked it out - too simple :blush: :

$special_order_number is now pre-populated but can be changed to any other number

Just need to make it hidden...

Thanks / Frank

One way...

<?php echo zen_draw_input_field('special_order_number', zen_output_string_protected($special_order_number), ' size="30" id="special_order_number" style="visibility:hidden; display:none;" autocomplete="off"'); ?>

If you do use the input tag, you could disable it so it shows but they are unable to edit it...

<?php echo zen_draw_input_field('special_order_number', zen_output_string_protected($special_order_number), ' size="30" id="special_order_number" disabled="disabled" autocomplete="off"'); ?>

But gee... it's hidden, why use input at all.. :blink: long day looking for a gost in my code....

<?php echo zen_draw_hidden_field('special_order_number', $special_order_number); ?>

Keep it somewhere between the form tags and it will work...

Dave
Always forward thinking... Lost my mind!

18 Nov 2013, 5:47 AM
#4
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: How to pre-populate hidden field in php email form?

davewest:

But gee... it's hidden, why use input at all.. :blink: long day looking for a gost in my code....

<?php echo zen_draw_hidden_field('special_order_number', $special_order_number); ?>
> Keep it somewhere between the form tags and it will work...

Thanks Dave, that's exactly what I did.

BTW: I know all to well about 'code blindness' - shame the only cure is going to bed....

Cheers / Frank

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.