php - 如何在 php 电子邮件上显示 php 单选输入值?
问题描述
我有一个带有 4 个无线电输入的 php 表单,如下所示:
<?php if( $chauffeur_data['enable-paypal'] == '1' ) { ?>
<div class="radio-wrapper clearfix"><input type="radio" name="payment-method" value="paypal" <?php if( $paypal_check == '1' ) { echo 'checked="checked"'; } ?> /><label><?php esc_html_e('Pay with PayPal','chauffeur'); ?></label><img src="<?php echo plugins_url('../../assets/images/paypal.png', __FILE__); ?>"></div>
<?php } ?>
<?php if( $chauffeur_data['enable-stripe'] == '1' ) { ?>
<div class="radio-wrapper clearfix"><input type="radio" name="payment-method" value="stripe" <?php if( $stripe_check == '1' ) { echo 'checked="checked"'; } ?> /><label><?php esc_html_e('Pay with Credit Card','chauffeur'); ?></label><img src="<?php echo plugins_url('../../assets/images/stripe.png', __FILE__); ?>"></div>
<?php } ?>
<?php if( $chauffeur_data['enable-cash'] == '1' ) { ?>
<div class="radio-wrapper clearfix"><input type="radio" name="payment-method" value="cash" <?php if( $cash_check == '1' ) { echo 'checked="checked"'; } ?> /><label><?php esc_html_e('Pay with Cash to the Driver','chauffeur'); ?></label></div>
<?php } ?>
<?php if( $chauffeur_data['enable-pos'] == '1' ) { ?>
<div class="radio-wrapper clearfix"><input type="radio" name="payment-method" value="pos" <?php if( $pos_check == '1' ) { echo 'checked="checked"'; } ?> /><label><?php esc_html_e('Pay with Card on POS in the Car','chauffeur'); ?></label></div>
<?php } ?>
<?php // If all payment gateways are disabled
if( $chauffeur_data['enable-paypal'] != '1' && $chauffeur_data['enable-stripe'] != '1' && $chauffeur_data['enable-cash'] != '1' &&
$chauffeur_data['enable-pos'] != '1' ) { ?>
<input type="hidden" name="payment-method" value="cash" />
<?php } ?>
<button name="pay_now" id="pay_now" class="payment-button" type="submit">
<?php esc_html_e('Proceed To Payment','chauffeur'); ?>
</button>
<?php } else { ?>
<input type="hidden" name="payment-method" value="cash" />
<button name="pay_now" id="pay_now" class="payment-button" type="submit">
<?php esc_html_e('Proceed To Book','chauffeur'); ?>
</button>
<?php } ?>
当检查一个广播按钮时,如何向我发送的电子邮件显示其值(例如POS)?
电子邮件如下所示。我的代码应该是什么来显示单选按钮选择?
$customer_email_content .= '<li><strong>' . esc_html__('Payment Method you Selected','chauffeur') . ': </strong>' . '**payment-method-goes-here**' . '</li>'."\r\n";
解决方案
表单提交后,从 $_POST 数组中获取单选按钮值;
$payment_method = $_POST['payment-method'];
使用 $payment_method 显示选中的单选按钮的值。
$customer_email_content .= '<li><strong>' . esc_html__('Payment Method you Selected','chauffeur') . ': </strong>' . $payment_method . '</li>'."\r\n";
推荐阅读
- r - 如何从嵌套的 JSON 格式 API 内容创建简单的数据框
- encryption - 使用 .pem openssl 解密 .enc
- ios - 升级到 ios 13 时 xcodebuild 存档失败
- ios - 无法将结构变量设为可变类型
- javascript - 无法让数据在网页上正确显示
- javascript - JavaScript 对象未实例化
- c# - 使用 Assert.Contains 在 xUnit 中进行测试
- mysql - 在mysql中将时间转换为“h:mm:a”
- python - 使用 Python 标准库从正确的名称(字符串)中获取星期几代码(int)
- python - 如何创建 3 个列表的所有可能组合的列表?