回显函数值不会传递到表单上 [英] echo a function value won't pass on a form

查看:112
本文介绍了回显函数值不会传递到表单上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

----更新:试图寻找不同的解决方案这里,请看看 ----- -
我试图在支付网关的商店平台上发布带有隐藏值的表单以接收值。
值名称Order_Total使用名为$ sum的PHP回显来显示支付的金额,如下所示:

 < Input type =hiddenname =sumvalue =<?php echo $ order_total;?>> 

$ sum是读取用户订单ID金额的函数

  $ order_total = left_to_pay_for_order($ oid); 

该功能如下所示:

 函数left_to_pay_for_order($ oid)
{


global $ wpdb;
$ s =select * from。$ wpdb-> prefix。order_contents where orderid ='$ oid'and paid ='0';
$ r = $ wpdb-> get_results($ s);
$ total = 0;
if(count($ r)> 0)
{
foreach($ r as $ row)
{
$ total + = $ row->价格* $ row-> quant;
$ shp = get_post_meta($ row-> pid,'shipping',true)* $ row-> quant;
$ total + = $ shp;
}

}

return $ total;
}

支付网关接收除$ order_total值之外的所有其他值。



更新! --------------------------------
作为'0'传递的值 - 任何想法都可能发生?


在发送表单和重定向之前,我已经过测试并且该函数可以工作,根据任何HTML上的预期结果发送,但表单发送值0。



我做错了什么?到处搜索。

谢谢!!



根据这里的要求,整个表单页面每个StackOverflow修改代码:

 <?php 

全局$ wp_query,$ wpdb,$当前用户;

get_currentuserinfo();
$ uid = $ current_user-> ID;
$ user_email = $ current_user-> user_email;

$ business = get_option('Theme_tranzilla_ID');
if(empty($ business))die('ERROR。请输入您的tranzilla ID。');
// -------------------------------------------- -----------------------------
$ oid = $ _GET ['oid'];
$ order_total = Theme_left_to_pay_for_order($ oid);
$ title_post = sprintf(__('Order Payment ID#:%s','Walleto'),$ oid);


// ---------------------------------


$ tm = current_time('timestamp',0);
$ cancel_url = get_bloginfo(siteurl);
$ response_url = get_bloginfo('siteurl')。'/?w_action = tranzila_order_response';
$ ccnt_url = Theme_my_account_link();
$ currency = get_option('Theme_currency');

?>


< html>
< head>< title>处理Tranzilla付款...< / title>< / head>
< body onLoad =document.form_mb.submit();>
< center>< h3><?php _e('请稍等,您的订单正在处理中...','主题'); ?>< / H3>< /中心],[

< FORM name =form_mbAction ='https://direct.tranzila.com/Terminal_Name/'method ='POST'>
< Input type =hiddenname =suppliervalue =<?php echo get_option('Theme_tranzilla_ID')?>>
< Input type =hiddenname =sumvalue =<?php echo $ order_total;?>>
< Input type =hiddenname =currencyvalue =1>
< input type =hiddenname =emailvalue =<?php echo $ user_email;?>>

< / FORM>




< / body>
< / html>


解决方案

请告诉我们您在检查..什么值在输入之前发布。

但是..根据您提供的信息,我认为:

  1)您缺少a;在echo $ order_total行的末尾。放一个;到底。 
2)这可能是一些wordpress与总和字段名称冲突。尝试更改为order_total。


----UPDATE: trying to find a different solution here, please take a look ------- I am trying to post a form with hidden values on a shop platform with payment gateway to receive the values. The value name "Order_Total" uses php echo called "$sum" to display the sum to pay like this:

<Input type="hidden" name="sum" value="<?php echo $order_total; ?>"> 

$sum is a function which reads the user order id amount

$order_total    = left_to_pay_for_order($oid);

the function works like this:

function left_to_pay_for_order($oid)
{


global $wpdb;
    $s = "select * from ".$wpdb->prefix."order_contents where orderid='$oid' and paid='0'";
    $r = $wpdb->get_results($s);
    $total = 0;
    if(count($r) > 0)
    {
        foreach ($r as $row)
        {
            $total += $row->price * $row->quant;    
            $shp = get_post_meta($row->pid, 'shipping', true)* $row->quant;
            $total += $shp;
        }

    }

return $total;
}

The Payment gateway receives all other values except the $order_total value.

UPDATE !!! -------------------------------- The value passed as '0' - Any thoughts on that can happen ?

I have tested and the function works prior to sending the form and redirect, the sum display according to expected result on any HTML prior to sending, but the form send value "0".

what am I doing wrong? have searched everywhere. your kind help is very much appreciated.

Thanks !!

As per request here is the whole Form page Code - modified per StackOverflow:

    <?php

    global $wp_query, $wpdb, $current_user;

    get_currentuserinfo();
    $uid = $current_user->ID;
    $user_email = $current_user->user_email;

    $business = get_option('Theme_tranzilla_ID');
    if(empty($business)) die('ERROR. Please input your tranzilla ID.');
    //-------------------------------------------------------------------------
    $oid = $_GET['oid'];    
    $order_total = Theme_left_to_pay_for_order($oid);
    $title_post = sprintf(__('Order Payment ID #: %s','Walleto'), $oid);


    //---------------------------------


    $tm             = current_time('timestamp',0);
    $cancel_url     = get_bloginfo("siteurl");
    $response_url   = get_bloginfo('siteurl').'/?w_action=tranzila_order_response';
    $ccnt_url       = Theme_my_account_link();
    $currency       = get_option('Theme_currency');

?>


<html>
<head><title>Processing Tranzilla Payment...</title></head>
<body onLoad="document.form_mb.submit();">
<center><h3><?php _e('Please wait, your order is being processed...', 'Theme'); ?></h3></center>

<FORM name="form_mb" Action='https://direct.tranzila.com/Terminal_Name/' method='POST'>
<Input type="hidden" name="supplier" value="<?php echo get_option('Theme_tranzilla_ID') ?>"> 
<Input type="hidden" name="sum" value="<?php echo $order_total; ?>"> 
<Input type="hidden" name="currency" value="1"> 
<input type="hidden" name="email" value="<?php echo $user_email; ?>">

</FORM>




</body>
</html>

解决方案

Please, tell us what you see in a "inspect".. what the value in the input before post.

But.. with information that you give, I think:

1) You are missing a ; in the end of "echo $order_total" line. Put a ; in the end.
2) It can be some wordpress conflict with the "sum" field name. Try to change to "order_total".

这篇关于回显函数值不会传递到表单上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆