I am trying to create a game with PHP. I have an iframe in index page all functions are in same class but I can't access the variables from the functions if I am calling a function in iframe function page. I have tried $_SESSION , but it didn't work,they are empty,help
When using Sessions, did you call the session_start function?
You can pass it with a GET variable in the URL on the iframe src attribute (if that's not a sensitive data or something like that).
Related
I'm working with PHP and in this instance I want to pass $_SESSION which I've already assigned with my currentUser object. This works fine.
I've used the header function to pass variables between pages such as header('Location: example.php?uID='.$uID) and then using GET to receive this value.
However, instead of using a header to automatically redirect, I want to use a href so that the user has to click on a link, which then initiates the redirect.
The problem is that I use the anchor (<a>) inside the PHP tags and I can't pass variables using it inside the HTML tags.
I'd be very grateful for the solution and happy to elaborate. Thank you!
You can do it that way :
//assuming that the user id is stored in the 'uID' field of $_SESSION
Redirect me !
I created a function that requires one parameter to be passed into it but I need that parameter to come from another script. How do I embed the variable into a link then put that variable into the function in another script? I know I need to utilize $_GET, isset($_GET['']) and a href but I just can't put it all together.
$_GET is collection of of query string parameters. If you had a url like: test.php?param1=foo¶m2=bar you can access foo by $_GET['param1'] etc..
Use $_REQUEST['something']
Your link must be:
Click Me
Inside test.php
if(#$_REQUEST['something']=="something"){
echo $_REQUEST['something1'];
}
When you click Click Me, test.php would echo "test".
How can i pass variable from codeigniter view to the external core php page which is included in that view ?
For example,
codeigniter view name is "login" and i have included a external php file name "logininner.php" and i want to pass a variable from "login" to "logininner.php".
can any one tell me a way to do this?
You can call $this->load->view(); just like you would in a controller function. So in your view, you can do something like this
<?php $this->load->view('logininner', array('variable1' => 'value')); ?>
Then, in logininner.php you'll have $variable1 set to the string value.
I have a page that is included as an iframe in my site. I need to supply the searched keyword to that page for DFP attribute and so I am setting the searched keyword as a global variable and now I need to retrieve the global variable in that iframe. So is it possible, and if so, how?
You can not access global variable in iframe because both will be separate request to server.
Either you need to pass variable as paramater in iframe src or you need to bind session variable in parent page and use that session value in iframe page.
You don't access this global variable in iframe because of limited scope. You can pass this variable in quarystring parameter. As like for example :-
<?php
var $param="test";
echo "<iframe src='test.php?param=".$param."'></iframe>";
?>
I hope it may helps!!
I have a php page, which using javascript, creates a popup window which contains another php page. the php page in the popup window is basically a form, and will use that value to insert into a database. Using the following function to load the php page in a popup:
phppopup('edit_status.php?cmd=EditStatusData')
function phppopup(page){
child1 = window.open (page, "Ebay Auctions", "height=600,width=600,status=yes,toolbar=no,menubar=no,location=no");
child1.document.close();
}
How can i pass a value from the calling page to the page in the popup?
I am trying at the moment:
echo "<p>Edit User Info
<p>Historie;
Which generates the following html:
Edit User Info
</strong></strong></strong></strong></p><p><strong><strong><strong><strong>Historie
It works fine for updateByEdit, why not for phpopup?
$pk is just an integer, which display fine in the page it the window is called from.
Well, you're already doing it - the GET variable in edit_status.php will have one entry, with key='cmd' and value='EditStatusData'. Just pass as many parameters as you need (while being mindful that such data will be publicly viewable).
Just add the arguments as part of the get request:
phppopup("index.php?var1=value1&var2=value2"); // Get
etc.
Alternatively, for passing it arguments when it is open already, use the handle that is returned (child1) and access that window's DOM via javascript.
child1.document.getElementById("myelement").innerHTML = "Hello World"; // Parent Child
If you have trouble with this, get the child window to trigger a callback in the parent window via window.opener when the child document has loaded, e.g.
window.opener.myCallback(requestedinfo); // Parent window callback function
I noticed that the generated HTML contains a query string that has HTML entities ('& amp;') instead of their actual equivalents. Make sure that updateByEdit(...) isn't returning entities or the query string won't be printed correctly.