Read POST variables in the Joomla 3 article url - php

Here is the scenario that i am working with and currently stuck at a point.
Joomla article calls a HTML form using sourcerer plugin.
SO in the article i have something like
[source] << include form.html >> [/source]
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 -->
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

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

Related

get and add php variable in wordpress page

hi i create one custom page in WordPress like page-download.php
i access this page like
http://example.com/download
its word fine but i want access this page like
http://example.com/download?n=skype
http://example.com/download?n=firefox
etc every time n value change.
and also i want get n value in page-download.php
please tell me how to do it . i know how to work in php simple but in wordpress its not work
Why just not use, echo $_GET['n'] ?
When you hit this page directly from the URL like below, please change your parameter, because of that I have tried same method few days ago and I can't get the parameter value.
http://example.com/download?from_browser=skype
http://example.com/download?from_browser=firefox
You can get the value like below or as per the reference :
$blah = get_query_var( 'from_browser');
if(isset($blah)) // Your code will be here
Hope this help!!!

Initializing the php form created with Formtools.org

I'm working on a form with Form tools http://www.formtools.org
My task is to create php multi-page form, using their API. And it should also save data after every step, not only after the last one.
But I already have a problem while initializing the form into the system.
I have all pages built, and when I'm doing test submission it works good. I successfully see my 'Thank you page'.
Following is the code from my 1st page
<?php
require_once("/app-administration/global/api/api.php");
$fields = ft_api_init_form_page("", "test");
$params = array(
"submit_button" => "submit",
"next_page" => "lc_2.php",
"form_data" => $_POST
);
ft_api_process_form($params);
?>
Then, due to the tutorial, I go to the admin panned, create new form there. And then, I need to initialize it.
So, I'm changing this line:
$fields = ft_api_init_form_page(12, "initialize");
But then, when I try to submit the form I get 100 error on the last page:
http://docs.formtools.org/api/index.php?page=error_codes#100
It says there is something with ID, but 12 is correct one because I have it from admin panel, and I double-checked it there.
Anybody have any ideas why I might have this error? Any help will be appreciated.
Thanks

Paypal custom field

Now with Paypal we do not get to many custom fields and only one standard IPN receiving file, what means we have to split the Instant Payment Notification up to send to the applying website.
Now I was thinking to do this with the custom field.
Basically I post a custom value with the websitename and customer_id_number, what can by example look like this: 'website1 12345'.
Now to shift out the website name is easy as I can make multiple "if's" and "and if's" for that like:
if ($custom == 'website1%') {}
But now I of course want to shift out the customer_id_number, that is in this example 12345.
Typing by example something like:
$customer_id_number = somewaytoshiftthenumberout;
Is there a special technique of doing this and of so can you guys put me into the right direction?
Thanks in advance!
I suggest you to use explode.
Write for example website1||12345, and use :
$custom_exploded = explode('||', $custom);
if ($custom_exploded[0] == 'website1')
// insert in DB $custom_exploded[1]

Wordpress/PHP - Custom action on comment post

Whenever a user posts a comment, I'd like to basically have a copy of the post sent to another database for a separate site. The database part is simple, but I can't seem to find the right action hook for this. (I did my testing with a simple echo statement, a failure being it not displaying at all) 'comment_save_pre' would only work when updating a comment, 'wp_set_comment_status' only works when the comment is approved, and 'comment_post' didn't seem to work at all. Does the hook exist?
add_action('...?...', 'on_comment_post');
function on_comment_post($comment){
echo "Test";
}
You can use comment_post :
Runs just after a comment is saved in the database. Action function
arguments: comment ID, approval status ("spam", or 0/1 for
disapproved/approved).

optional_param in form

I have a question about the optional_param function in a form in PHP (version 5.3.14)
After looking over why certain fields were not being saved in a form I have, I realised that this data...
$checkdata = optional_param('items', array(), PARAM_INT)
Only saves up to 996 places (items) from the form (they are select items and there are many)....
Is this a setting or a something I can change? or alternatively something wrong from my end?
Thanks in advance
Solution : A moodle function (platform i am working with)
Thanks Pekka
this function is a moodle function. It gets a parameter from the current page URL.
For an example url:
http://moodle.dev/course/view.php?id=2&items=4
(this is chosen totally arbitrary)
Using this code:
$checkdata = optional_param('items', array(), PARAM_INT)
Will save the "items" value (here it's 4) in $checkdata. If items does not exist in the url it will do $checkdata = array()

Categories