views:

360

answers:

2

(First posting, so please be merciful if I'm off on some of the etiquette, markup, etc. :))

Server-side:

iframe-contents.php:

<?PHP

if($_POST['test-post-parameter'] == 'test-post-value'){
echo 'test-post-parameter successfully detected as "test-post-value".';
} else {
echo 'test-post-parameter either absent or of a different value than "test-post-value". :(';
}
?>


OK, so lets say i request iframe-contents using

bash$ wget --post-data='test-post-parameter=test-post-value' -O - http://example.com/iframe-contents.php

The result would be:

test-post-parameter successfully detected as "test-post-value".


If, however, I requested it using

`bash$ wget -O - http://example.com/iframe-contents.php`

I would end up getting:

test-post-parameter either absent or of a different value than "test-post-value


Now - lets say I have another file on the server, called index.html:

<html><head><title>PAGE_TITLE</title></head>
<body>
<iframe width="100%" height="100%" src="iframe-contents.php" />
</body>


If I tried typing http://example.com/index.html into my browser, I would get PAGE_TITlE in my titlebar, with test-post-parameter either absent or of a different value than "test-post-value". :( in the body.

My question is this: How can I modify the iframe element so that I get

test-post-parameter successfully detected as "test-post-value".

?

A: 

I'm not sure you can do it for post parameters, but in case you will use get method you can pass parameters explicitly:

<html><head><title>PAGE_TITLE</title></head>
<body>
<iframe width="100%" height="100%" src="iframe-contents.php?test-post-parameter=value" />
</body>
Artem Barger
+1  A: 

You cannot. You can do it by using GET.

With POST: Maybe only if you make a temporary .php page, that has a form with that post value, and a javascript script that automatically post the form and redirects you to the iframe-contents.php

Something like this:

temp-iframe.php

<html><head>
</head>
<body onLoad="document.forms.myForm.submit()">
<form name="myForm" id="myForm" action="POST" target="iframe-contents.php">
<input type="hidden" id="test-post-parameter" value="test-post-value">
</form>
</body>
</html>

And in the iframe src you add the: temp-ifram.php

Hope it helps.

Timotei Dolean