Nilesh Puranik
Nilesh Puranik

Reputation: 297

Read POST variables in the Joomla 3 article url

Here is the scenario that i am working with and currently stuck at a point.

  1. Joomla article calls a HTML form using sourcerer plugin. SO in the article i have something like [source] << include form.html >> [/source]

  2. On submit, Form.html send a AJAX POST call to a PHP file updates a Db table and then opens a new URL which is a payment gateway.

<-- This is where my problem lies -->

  1. I need to give return URL to my payment gateway so that after successful payment it redirects to this page along with the transaction id as a parameter in URL.(For ex : www.mywebsite.com/thank-you/?trxid=131213&uniqueid=23424234 )

I need to capture this transaction id and print it in the article saying "Thank you for your payment. Your transaction id is xxxxxxxx ".

How should i proceed with the development ? How can i capture the POST / GET parameters in the Joomla article ?

Can anyone help me here?

Thanks in advance.

BR Nilesh

Upvotes: 0

Views: 742

Answers (1)

Terry Carter
Terry Carter

Reputation: 300

If you are already using Sourcerer in your articles you should be able to embed your PHP code between your [sourcerer][/sourcerer] tags. The following PHP code will all you to query the post variables in your URL:

$JInput = JFactory::getApplication()->input;
$trxid = $JInput->get('trxid','','int');
$uniqueid = $JInput->get('uniqueid','','int');

That will set your values to the variables $trxid and $uniqueid. From there you can print them in your article using the sourcerer tags and an echo or print statement.

Change the 'int' to 'string' if those fields may be alphanumeric mixed strings.

Cheers and Good Luck

Here is the link for the Joomla documentation on using JInput as well for future use if you need it. Using JInput with Joomla

Upvotes: 1

Related Questions