Krystian
Krystian

Reputation: 458

PHP run in iframe

I created iframe where source is my PHP file, the file should display data from GET method the code is:

<?php   
if (isset($_GET["phpMap"])){
var $response = $_GET["phpMap"];
echo $response;
}
?>

but when i run button that send data to that iframe nothing happens.

Upvotes: 1

Views: 9942

Answers (4)

colosso
colosso

Reputation: 2525

You have to change the $_GET into $_POST then it should work with a button click.

If you need to send data from outside of the iframe into the iframe you need to make sure that you write query strings in theurl of the iframe source:

<iframe src="yourfile.php?var=someting"></iframe>

Like that you can recieve the valeue of $var in the script with

<?php $variable = $_GET['var'] ?>

Upvotes: 0

Hardik Raval
Hardik Raval

Reputation: 1940

Plz correct your code as follow, remove "var"

<iframe src="iframe.php?phpMap='google'" ></iframe>

in iframe.php put code

if (isset($_GET["phpMap"])){$response = $_GET["phpMap"]; echo $response; }

Upvotes: 3

xXPhenom22Xx
xXPhenom22Xx

Reputation: 1275

You also dont need to declare your variable like that outside of a Class.

$response = $_POST['phpmap']; 

You can also troubleshoot by adding print_r['$_POST'] or print_r['$_GET'] at the top of the script to see what variables if any are coming over. Firebug is also good for capturing POST/GET transmissions and allowing you to see the values being passed back and forth.

Upvotes: 0

William Dixon
William Dixon

Reputation: 101

If data is sent using POST then you should update your code and change $_GET[] to $_POST[]

Upvotes: 0

Related Questions