Cakephp 3.0, get id from URL when using on IFrame - php

I am using CakePHP project in IFrame. I have a query string bid in the URL.(Eg: http://localhost:8765/?bid=Mjc). Initially I use $_GET['bid']. Later I have used $this->request->query['bid'].
The last method I used is working fine when I call the URL directly into the browser. But when I call the URL from IFrame(Eg: <iframe src='http://localhost:8765/?bid=Mjc' id='WidgetFrame'>), the $this->request->query array comes empty.
Could any one please suggest me best method to get bid from URL.
NOTE: Using $_GET['bid'] working on both Browser and IFrame.
Thanks.

Related

In html we use href for navigating to another page. how to perform the same operation in php

I am very beginner in php.I need to know how to fetch the data from the url and pass it to another page using html.
http://localhost/userdetails.php?branchId=2
This is my url i need to get the value branchId=2 and pass it to next page userdetails.2php what is the syntax for this operation As a beginner am having trouble in doing that.
When getting parameters from url, use $_GET. So in userdetails.php, use
$_GET['branchId'];

transferring a variable through different web pages in wordpress

Currently I'm building a plug-in for wordpress, where I have a couple of webpages with tables, filled with data from a database. Right now I'm working on the part where I click on a number (MemberID) which should redirect to a page, having all the information from another table regarding this number. I've tried transfering the data through the URL, with both
?MemberID=".$item->MemberID."
and
/MemberID="$item->MemberID."
, but everytime I try to alter the URL, the webpages suddenly can't seem to find itself anymore. I'm sure it has to do whith this part of the code:
add_submenu_page( null , 'Manage memberDetails' , 'memberDetails' , 'manage_options', 'memberDetails' , 'memberDetails_list' );
where the fifth value sets the URL for this page to be
http://localhost/wordpress/wp-admin/admin.php?page=memberDetails
So whenever I try to add something behind that URL, it doesn't acknowledge the existance of said page anymore, resulting in a redirection error.
Is there a way to transfer the variable without using the URL, or is there a way to give more of a dynamic to the URL?
You are using add_submenu_page wrong. The first param is required and can not be null.
https://codex.wordpress.org/Function_Reference/add_submenu_page
You need to get that fixed first so you page properly works.
As someone pointed my fairly basic mistake out this is what went wrong:
The URL is
http://localhost/wordpress/wp-admin/admin.php?page=memberDetails
where I tried to turn it into
http://localhost/wordpress/wp-admin/admin.php?page=memberDetails/memberID=
which creates a whole new webpage and is therefor impossible in this case. I need to transfer the variable behind the memberID=, not refer to a whole new webpage. The other thing I tried to do was
http://localhost/wordpress/wp-admin/admin.php?page=memberDetails?memberID=
which is impossible, because the second ? in the URL needed to be replaced with a &
From there on, it was pretty easy to use $_GET to retrieve the variable from the URL and use it.
So for extra clarity, this is how the URL is supposed to look
http://localhost/wordpress/wp-admin/admin.php?page=memberDetails&memberID=

Add this share not working in ajax call

I was using add this share plugin.I am creating dynamic data url from ajax call.
My code was:
addthis.init();
$('.addthis_sharing_toolbox').attr('data-url',dta);
My problem current page url only sharing. I need to send my custom url. Any answer will be appreciated.
First, make sure the variable dta has the URL you'd like to use. Then, follow the instructions on this page to update the URL and title that are shared: http://support.addthis.com/customer/portal/articles/1692927-using-dashboard-configuration-tools-dynamically
Specifically, call the addthis.layers.refresh() function.

Pagination together with a html form

On my website I use a pagination (similar to that one on the bottom of this page) for MySQL output. For the change of the current page I use GET method (variable page) and it works well.
However, on my page I have also a form, using method POST, which acts as a filter for the MySQL output. This rises a problem because, when I change the form settings an submit them (POST), the page in the address line (GET) remains the same. This is problem in some cases when the filtered output has less pages than that one currently set.
Is it somehow possible to set the page variable to 0 always when the form is submitted?
Particularly, I did it using $_SERVER['REQUEST_METHOD'] == 'POST'. However, this changes just the variable in the code. Not at the address line.
On the other hand I want to keep the POST variable when I change the page of the output.
Thanks in advance.
There is a logical collision in your setup:
Unlike GET method, POST method doesn't keep variables in the address bar. But for some reason you are using POST method.
So, the solution is quite simple - use GET method for the filtering.
To create pagination links use http_build_query() out of $_GET array
In fact it's better to send filter criteria in the address (GET method). It will solve your problem with pagination and you (and your users) will have a direct link to search results.
In your PHP code, you want to redirect to the URL with the page GET parameter removed if you are SUBMITTING (by pressing the "Filter" button, or whatever it's called). So it will start at page 0.
You would have to rewrite the URL yourself (or using a plugin).
Typo corrected, I meant page 0, not 1 :P

JavaScript Redirection Loop

I'm trying to implement a Facebook connect button to my website.
It's working, but it's written in JavaScript and I'd like to insert the information into the database (the tutorial I used is linked below.)
I'm trying to redirect the users from the index.php to index.php?name=xxx.
The name value is rendered with JavaScript so I can't simply just set a PHP variable, can I?
I've been told it's possible with $_GET so that's what I'm trying to achieve.
Using location.href/replace, both redirect to the same page over and over again...
This is the tutorial I used.
I would like to store some information in the database, but I can't do it directly since it's JavaScript and not PHP.
Is there a solution/any other way?
check if the name parameter is filled or not, and if it is, do not redirect

Categories