如何使用GET从网址中获取两个值对

时间:2018-09-29 10:11:50

标签: php redbean

伙计们,我正在编写代码以从另一个页面请求服务,当该页面重定向到我的网站时,下面是该页面返回的URL。但是现在的问题是我只能获得一个参数,即period_id。

https://leadingdigital.co.zw/maz/member/payments.php?ref=1538214143&period_id=3

    $reference = $_GET['ref'];
    $id = $_GET['period_id'];

我正在通过GET获得我的价值观。但是对于我来说,然后使用这两个值访问我的数据都行不通。它仅在我从网址中删除引用时才有效。好像不是这样,对于从$ id = $ _GET ['period_id']中获取值后需要period_id的代码块;它起作用,然后对于需要$ reference = $ _GET ['ref']的块;可能会失败。

因为在我的情况下,这两个块均失败。 这是需要$ reference = $ _GET ['ref']中的值的块; 如果引用不为null,则将执行以下代码

    if ($reference != null) {
        $info = R::findOne('paynowtransaction', 'WHERE reference = ?', [$reference]);
        require 'vendor/autoload.php';
        $url = $info->pollurl;
        $response = \Httpful\Request::post($url)->send();

        $stageone = explode('&', $response);
        $data = array();

        for ($i = 0; $i < sizeof($stageone); $i++) {
            $item = explode('=', $stageone[$i]);
            $data[$item[0]] = $item[1];
        }
        $status = $data['status'];
        $paynowref = $data['paynowreference'];
        $email = $info->email;
        $amount = $data['amount'];
        $message = "<h4>Your Payment of " . $amount . " with reference " . $paynowref . " has been made. Your payment status is :" . $status . "</h4><br/>";
        $message .= "<h4>Thank your for doing business with us!</h4>";


        if ($status != null) {
            $update = R::findOne('paynowtransaction', 'WHERE reference = ?', [$reference]);
            $update->status = $status;
            $update->paynowreference = $paynowref;

            R::store($update);

            //now save from paynowtransaction to payments
            $payments = R::dispense('payments');
            $payments->payment_date = $update->payment_date;
            $payments->amount_invoiced = $update->amount_invoiced;
            $payments->amount_paid = $amount;
            $payments->period_id = $update->period_id;
            $payments->pop = $paynowref;
            $payments->payment_method = 3;
            $payments->member_id = $update->member_id;
            $id = R::store($payments);

            $period_balance = R::load('renewal', $update->period_id);
            $new_balance = $period_balance->balance - $update->amount_paid;
            $period_balance->balance = $new_balance;
            if ($new_balance > 0) {
                $period_balance->payment_status = 2;
            } else {
                $period_balance->payment_status = 1;
            }
            R::store($period_balance);

        }
    }

这是需要$ id = $ _GET ['period_id']中的值的块; 如果$ id具有某些内容,则必须像下面的脚本那样加载数据。 我已经尝试过了,但是它不起作用,我必须首先从url中删除引用,这样它才能起作用

$payment_period = R::load('renewal', $id);

0 个答案:

没有答案