Skip to content
Advertisement

PHP form issue after submit

ill try to submit this form:

<form name="quick_login" class="loginfrm" action="[{$oViewConf->getSelfActionLink()}]cl=subtel_account_extend_bill_details" method="post">
    <input type="hidden" id="oxid" name="oxid" value="[{$oViewConf->getoxtrckID()}]">

    <div class="form-group">
        <label for="loginEmail_[{$style}]">[{oxmultilang ident="WIDGET_LOGINBOX_EMAIL_ADDRESS"}]</label>
        <input type="text" id="email_track" name="email_track" class="form-control" required>
    </div>
    <div class="form-group">
        <label for="ordernr_track_[{$style}]">[{*oxmultilang ident="WIDGET_LOGINBOX_PASSWORD"*}]Order number</label>
        <input type="text" id="ordernr_track" name="ordernr_track" class="form-control" required >
    </div>

    <button type="submit" class="btn [{if $style eq 'desktop'}]btn-sm[{else}]btn-lg[{/if}] btn-info start_login">[{*oxmultilang ident="LOGIN"*}]Show order</button>
    <br/>
    <br/>
</form>

after fill in email and ordernr. ill get redirectet to an empty page when i debug i gett my oxid. I want to get the oxid first and redirect after getting the oxid so i can go to the order im searching for.

ill try a lot of things these past 2 days but nothing works.

thats my functio to get the oxid

public function getoxtrckID()
{
    $sEMail = oxRegistry::getConfig()->getRequestParameter('email_track', true);
    $sONumber = oxRegistry::getConfig()->getRequestParameter('ordernr_track', true);
    $sArticleId = oxDb::getDb()->getOne("SELECT OXID FROM oxorder WHERE OXORDERNR = ? AND OXBILLEMAIL = ?", [$sONumber, $sEMail]);
    return $sArticleId;
}

Im not good at JS so ill tryed only php, can someone give me a little help, thanks a lot

Advertisement

Answer

you don’t need an actual redirect unless you want to prevent visitors from hitting F5 and reloading same page again, which is not necessary here.
Before we start: your variable $sArticleId contains an order Id, to keep the code understandable you should name it $sOrderId.

After you found your order Id you also need to load the order data like this:

$oOrder = oxNew("oxorder");
$oOrder->load($sOrderId);

In order to keep it simple, you can remove your hidden order id field, put the code for loading the order data into the render() function and pass the order object to the view (template):

public function render()
{
  ... your render code ...

  $sEMail = oxRegistry::getConfig()->getRequestParameter('email_track', true);
  $sONumber = oxRegistry::getConfig()->getRequestParameter('ordernr_track', true);
  // if form was submitted, both variables will be set
  if($sEMail && $sONumber)
  {
    // finding order 
    $sOrderId = oxDb::getDb()->getOne("SELECT OXID FROM oxorder WHERE OXORDERNR = ? AND OXBILLEMAIL = ?", [$sONumber, $sEMail]);

    if($sOrderId) // order found -> loading order data
    {
      $oOrder = oxNew("oxorder");
      $oOrder->load($sOrderId) 
      $this->addTplParam('oOrder', $oOrder);
    }
    else // order not found, display error message
    {
      oxRegistry::get("oxUtilsView")->addErrorToDisplay('Order not found'); 
    }
  }
  return $sTempalteName;
}

In your template you will get the oxOrder object will all the properties and methonds:

[{if $oOrder}]
  <h2>Your Order Data:</h2>
  [{$oOrder->oxorder__whateveryouwant->value }]
[{/if}]
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement