Php Form inputs in email
I created a form which will be entered by user
<form id="wc-form-return" action="" method="post">
<label><?php _e('Select products for return','wc_return') ?></label>
<select id="wc_products" name="wc_products" class="wc_products" multiple="multiple">
<?php
if ( sizeof( $products ) > 0 ) {
foreach( $products as $item ) { ?>
<option value="<?php echo $item['item_meta']['_product_id'][0]; ?>"><?php echo __(esc_html($item['name']), 'wc_return'); ?></option>
<?php
}
}
?>
</select>
<small><?php _e('You can select multiple by holding down the CMD or Ctrl key.','wc_return'); ?></small>
<textarea name="wc_message" id="wc_message" cols="30" rows="10" placeholder="<?php _e('Explain the reasons for your return', 'wc_return') ?>"></textarea>
<input type="hidden" name="order" value="<?php echo $order->id; ?>" />
<input type="hidden" name="customer" value="<?php echo $order->billing_email; ?>" />
<input type="text" name="phone" id="wc_phone" value="<?php echo $order->billing_phone; ?>" />
<input type="checkbox" name="check1" value="Yes" required>Accept our <a href="https://sabkishop.in/return"> return and exchange policy </a> </br>
<input type="submit" name="submit" value="<?php _e('Submit','wc_return'); ?>" />
</form>
It will be entered by user and we will be sent to given email (that is already setted up)
Now to give these information in email i used
$note_form_email = '';
if ( $_POST['wc_message'] != '' ) {
$note .= '<br><br>';
$note .= '<p>'.__('And the explanation:', 'wc_return').'</p>';
$note_form_email .= '<p>'.__('And the explanation:', 'wc_return').'</p>';
$note .= apply_filters( 'the_content', $_POST['wc_message'] );
$note_form_email .= apply_filters( 'the_content', $_POST['wc_message'] );
$note .= '<p>'.__('Customer details:', 'wc_return').'</p>';
$note_form_email .= '<p>'.__('Customer details:', 'wc_return').'</p>';
$note .= '<p>'.__('Customer phone:','wc_return').'</p>';
$note_form_email .= '<p>'.__('Customer phone:','wc_return').'</p>';
$note .= apply_filters('the_content', $_POST['wc_phone'] );
$note_form_email .= apply_filters('the_content', $_POST['wc_phone'] );
}
But output was like this
And the explanation:
Huhhh
Customer details:
Customer phone:
That 'Huhhh' was written by user on wc_message. He also wrote wc_phone but it was not showing in email. Wc_message is working properly but wc_phone isnt. What am i doing wrong?
php html wordpress forms
add a comment |
I created a form which will be entered by user
<form id="wc-form-return" action="" method="post">
<label><?php _e('Select products for return','wc_return') ?></label>
<select id="wc_products" name="wc_products" class="wc_products" multiple="multiple">
<?php
if ( sizeof( $products ) > 0 ) {
foreach( $products as $item ) { ?>
<option value="<?php echo $item['item_meta']['_product_id'][0]; ?>"><?php echo __(esc_html($item['name']), 'wc_return'); ?></option>
<?php
}
}
?>
</select>
<small><?php _e('You can select multiple by holding down the CMD or Ctrl key.','wc_return'); ?></small>
<textarea name="wc_message" id="wc_message" cols="30" rows="10" placeholder="<?php _e('Explain the reasons for your return', 'wc_return') ?>"></textarea>
<input type="hidden" name="order" value="<?php echo $order->id; ?>" />
<input type="hidden" name="customer" value="<?php echo $order->billing_email; ?>" />
<input type="text" name="phone" id="wc_phone" value="<?php echo $order->billing_phone; ?>" />
<input type="checkbox" name="check1" value="Yes" required>Accept our <a href="https://sabkishop.in/return"> return and exchange policy </a> </br>
<input type="submit" name="submit" value="<?php _e('Submit','wc_return'); ?>" />
</form>
It will be entered by user and we will be sent to given email (that is already setted up)
Now to give these information in email i used
$note_form_email = '';
if ( $_POST['wc_message'] != '' ) {
$note .= '<br><br>';
$note .= '<p>'.__('And the explanation:', 'wc_return').'</p>';
$note_form_email .= '<p>'.__('And the explanation:', 'wc_return').'</p>';
$note .= apply_filters( 'the_content', $_POST['wc_message'] );
$note_form_email .= apply_filters( 'the_content', $_POST['wc_message'] );
$note .= '<p>'.__('Customer details:', 'wc_return').'</p>';
$note_form_email .= '<p>'.__('Customer details:', 'wc_return').'</p>';
$note .= '<p>'.__('Customer phone:','wc_return').'</p>';
$note_form_email .= '<p>'.__('Customer phone:','wc_return').'</p>';
$note .= apply_filters('the_content', $_POST['wc_phone'] );
$note_form_email .= apply_filters('the_content', $_POST['wc_phone'] );
}
But output was like this
And the explanation:
Huhhh
Customer details:
Customer phone:
That 'Huhhh' was written by user on wc_message. He also wrote wc_phone but it was not showing in email. Wc_message is working properly but wc_phone isnt. What am i doing wrong?
php html wordpress forms
1
There is nowc_phone
input in your form, there only aphone
input.
– KIKO Software
Nov 22 '18 at 8:20
usesanitize_text_field
notapply_filters
– Vel
Nov 22 '18 at 8:22
Yes i am sorry now i added id of form phone
– Aman Singh
Nov 22 '18 at 9:28
I added sanitize_text_field instead of apply_filters but it gave me the_content text under customer phone: in email
– Aman Singh
Nov 22 '18 at 10:30
And the explanation: Hjgvbbvv Customer details: Customer phone: the_content
– Aman Singh
Nov 22 '18 at 10:30
add a comment |
I created a form which will be entered by user
<form id="wc-form-return" action="" method="post">
<label><?php _e('Select products for return','wc_return') ?></label>
<select id="wc_products" name="wc_products" class="wc_products" multiple="multiple">
<?php
if ( sizeof( $products ) > 0 ) {
foreach( $products as $item ) { ?>
<option value="<?php echo $item['item_meta']['_product_id'][0]; ?>"><?php echo __(esc_html($item['name']), 'wc_return'); ?></option>
<?php
}
}
?>
</select>
<small><?php _e('You can select multiple by holding down the CMD or Ctrl key.','wc_return'); ?></small>
<textarea name="wc_message" id="wc_message" cols="30" rows="10" placeholder="<?php _e('Explain the reasons for your return', 'wc_return') ?>"></textarea>
<input type="hidden" name="order" value="<?php echo $order->id; ?>" />
<input type="hidden" name="customer" value="<?php echo $order->billing_email; ?>" />
<input type="text" name="phone" id="wc_phone" value="<?php echo $order->billing_phone; ?>" />
<input type="checkbox" name="check1" value="Yes" required>Accept our <a href="https://sabkishop.in/return"> return and exchange policy </a> </br>
<input type="submit" name="submit" value="<?php _e('Submit','wc_return'); ?>" />
</form>
It will be entered by user and we will be sent to given email (that is already setted up)
Now to give these information in email i used
$note_form_email = '';
if ( $_POST['wc_message'] != '' ) {
$note .= '<br><br>';
$note .= '<p>'.__('And the explanation:', 'wc_return').'</p>';
$note_form_email .= '<p>'.__('And the explanation:', 'wc_return').'</p>';
$note .= apply_filters( 'the_content', $_POST['wc_message'] );
$note_form_email .= apply_filters( 'the_content', $_POST['wc_message'] );
$note .= '<p>'.__('Customer details:', 'wc_return').'</p>';
$note_form_email .= '<p>'.__('Customer details:', 'wc_return').'</p>';
$note .= '<p>'.__('Customer phone:','wc_return').'</p>';
$note_form_email .= '<p>'.__('Customer phone:','wc_return').'</p>';
$note .= apply_filters('the_content', $_POST['wc_phone'] );
$note_form_email .= apply_filters('the_content', $_POST['wc_phone'] );
}
But output was like this
And the explanation:
Huhhh
Customer details:
Customer phone:
That 'Huhhh' was written by user on wc_message. He also wrote wc_phone but it was not showing in email. Wc_message is working properly but wc_phone isnt. What am i doing wrong?
php html wordpress forms
I created a form which will be entered by user
<form id="wc-form-return" action="" method="post">
<label><?php _e('Select products for return','wc_return') ?></label>
<select id="wc_products" name="wc_products" class="wc_products" multiple="multiple">
<?php
if ( sizeof( $products ) > 0 ) {
foreach( $products as $item ) { ?>
<option value="<?php echo $item['item_meta']['_product_id'][0]; ?>"><?php echo __(esc_html($item['name']), 'wc_return'); ?></option>
<?php
}
}
?>
</select>
<small><?php _e('You can select multiple by holding down the CMD or Ctrl key.','wc_return'); ?></small>
<textarea name="wc_message" id="wc_message" cols="30" rows="10" placeholder="<?php _e('Explain the reasons for your return', 'wc_return') ?>"></textarea>
<input type="hidden" name="order" value="<?php echo $order->id; ?>" />
<input type="hidden" name="customer" value="<?php echo $order->billing_email; ?>" />
<input type="text" name="phone" id="wc_phone" value="<?php echo $order->billing_phone; ?>" />
<input type="checkbox" name="check1" value="Yes" required>Accept our <a href="https://sabkishop.in/return"> return and exchange policy </a> </br>
<input type="submit" name="submit" value="<?php _e('Submit','wc_return'); ?>" />
</form>
It will be entered by user and we will be sent to given email (that is already setted up)
Now to give these information in email i used
$note_form_email = '';
if ( $_POST['wc_message'] != '' ) {
$note .= '<br><br>';
$note .= '<p>'.__('And the explanation:', 'wc_return').'</p>';
$note_form_email .= '<p>'.__('And the explanation:', 'wc_return').'</p>';
$note .= apply_filters( 'the_content', $_POST['wc_message'] );
$note_form_email .= apply_filters( 'the_content', $_POST['wc_message'] );
$note .= '<p>'.__('Customer details:', 'wc_return').'</p>';
$note_form_email .= '<p>'.__('Customer details:', 'wc_return').'</p>';
$note .= '<p>'.__('Customer phone:','wc_return').'</p>';
$note_form_email .= '<p>'.__('Customer phone:','wc_return').'</p>';
$note .= apply_filters('the_content', $_POST['wc_phone'] );
$note_form_email .= apply_filters('the_content', $_POST['wc_phone'] );
}
But output was like this
And the explanation:
Huhhh
Customer details:
Customer phone:
That 'Huhhh' was written by user on wc_message. He also wrote wc_phone but it was not showing in email. Wc_message is working properly but wc_phone isnt. What am i doing wrong?
php html wordpress forms
php html wordpress forms
edited Nov 22 '18 at 9:27
Aman Singh
asked Nov 22 '18 at 8:13
Aman SinghAman Singh
13
13
1
There is nowc_phone
input in your form, there only aphone
input.
– KIKO Software
Nov 22 '18 at 8:20
usesanitize_text_field
notapply_filters
– Vel
Nov 22 '18 at 8:22
Yes i am sorry now i added id of form phone
– Aman Singh
Nov 22 '18 at 9:28
I added sanitize_text_field instead of apply_filters but it gave me the_content text under customer phone: in email
– Aman Singh
Nov 22 '18 at 10:30
And the explanation: Hjgvbbvv Customer details: Customer phone: the_content
– Aman Singh
Nov 22 '18 at 10:30
add a comment |
1
There is nowc_phone
input in your form, there only aphone
input.
– KIKO Software
Nov 22 '18 at 8:20
usesanitize_text_field
notapply_filters
– Vel
Nov 22 '18 at 8:22
Yes i am sorry now i added id of form phone
– Aman Singh
Nov 22 '18 at 9:28
I added sanitize_text_field instead of apply_filters but it gave me the_content text under customer phone: in email
– Aman Singh
Nov 22 '18 at 10:30
And the explanation: Hjgvbbvv Customer details: Customer phone: the_content
– Aman Singh
Nov 22 '18 at 10:30
1
1
There is no
wc_phone
input in your form, there only a phone
input.– KIKO Software
Nov 22 '18 at 8:20
There is no
wc_phone
input in your form, there only a phone
input.– KIKO Software
Nov 22 '18 at 8:20
use
sanitize_text_field
not apply_filters
– Vel
Nov 22 '18 at 8:22
use
sanitize_text_field
not apply_filters
– Vel
Nov 22 '18 at 8:22
Yes i am sorry now i added id of form phone
– Aman Singh
Nov 22 '18 at 9:28
Yes i am sorry now i added id of form phone
– Aman Singh
Nov 22 '18 at 9:28
I added sanitize_text_field instead of apply_filters but it gave me the_content text under customer phone: in email
– Aman Singh
Nov 22 '18 at 10:30
I added sanitize_text_field instead of apply_filters but it gave me the_content text under customer phone: in email
– Aman Singh
Nov 22 '18 at 10:30
And the explanation: Hjgvbbvv Customer details: Customer phone: the_content
– Aman Singh
Nov 22 '18 at 10:30
And the explanation: Hjgvbbvv Customer details: Customer phone: the_content
– Aman Singh
Nov 22 '18 at 10:30
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53426448%2fphp-form-inputs-in-email%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53426448%2fphp-form-inputs-in-email%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
There is no
wc_phone
input in your form, there only aphone
input.– KIKO Software
Nov 22 '18 at 8:20
use
sanitize_text_field
notapply_filters
– Vel
Nov 22 '18 at 8:22
Yes i am sorry now i added id of form phone
– Aman Singh
Nov 22 '18 at 9:28
I added sanitize_text_field instead of apply_filters but it gave me the_content text under customer phone: in email
– Aman Singh
Nov 22 '18 at 10:30
And the explanation: Hjgvbbvv Customer details: Customer phone: the_content
– Aman Singh
Nov 22 '18 at 10:30