/    Sign up×
Community /Pin to ProfileBookmark

Cannot An iFrame Have Variables As Their url alue ?

Folks,

This:

““
http://localhost/test/pagination_2.php?col=$col&search=$search&limit=$limit&page=$i
““

is equal to this:

““
http://localhost/test/pagination_2.php?col=domain&search=heman.com&limit=10&page=1
““

Url is a page that shows a pagination showing result of keyword search for “heman.com”.

Now, this following iframe opens to such a pagination showing result of keyword search for “heman.com”.

““
<iframe src=’http://localhost/test/pagination_2.php?search=heman.com&tbl=browsing_histories&col=domain&limit=’></iframe>
““

But the following 2 codes just opens to pagination_2.php. Browser not taking into account the params in the url. Why ?

1

““
$_SESSION[‘url ‘] = $url = “http://localhost/test/pagination_2.php?”;
$_SESSION[‘search’] = $search = $domain; //’$search’ value holds the ‘keyword’ to search.
$_SESSION[‘tbl’] = $tbl = ‘browsing_histories’;
$_SESSION[‘col’] = $col = ‘domain’; //’$col’ value holds the column to search.
$_SESSION[‘page’] = $page = 1;?>

<iframe src='<?php echo “.htmlentities($url)” .’?col=’ .urlencode($col) .’&search=’ .urlencode($search) .’&limit=’ .urlencode($limit) .’&page=’ .urlencode($page) .”‘></iframe><br>”;
““

2

““

printf(
“<iframe src=’%s?col=%s&search=%s&limit=%d&page=%d’></iframe><br>”,
htmlentities($url),
urlencode($col),
urlencode($search),
$limit, // %d place-holder will force integer
$i // ditto
);

““

How to fix ?

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 02.2020 — Since you're doing this:
<i>
</i>$url = "http://localhost/test/pagination_2.php?";

...you're ending up with double ?? when you do either of those, since you are outputting that variable and then explicitly also outputting another "?" in the string.
Copy linkTweet thisAlerts:
@developer_webauthorNov 03.2020 — @NogDog#1624795

After fixing the "?", issue did not solve.

What is wrong with these 5 codes ?

Attempt 1 (shows a dead page).

<iframe src='http://localhost/test/pagination_2.php?search=heman.com&tbl=browsing_histories&col=domain&limit=1'></iframe><br>


Attempt 2 (opens to page with no search results shown as if no params in url)

$_SESSION['url'] = $url = "http://localhost/test/pagination_2.php";
$_SESSION['search'] = $search = $domain; //'$search' value holds the 'keyword' to search.
$_SESSION['tbl'] = $tbl = 'browsing_histories';
$_SESSION['col'] = $col = 'domain'; //'$col' value holds the column to search.
$_SESSION['page'] = $page = 1;?>

<iframe src='<?php echo ".htmlentities($url)" .'?col=' .urlencode($col) .'&search=' .urlencode($search) .'&limit=' .urlencode($limit) .'&page=' .urlencode($page) ."'></iframe><br>";


Attempt 3 (opens to page with no search results shown as if no params in url)

$i = 1;
printf("<iframe src='%s?col=%s&search=%s&limit=%d&page=%d'></iframe><br>",
htmlentities($url),
urlencode($col),
urlencode($search),
$limit, // %d place-holder will force integer
$i // ditto
);


Attempt 4 (opens to page with no search results shown as if no params in url)

$i = 1;
echo "<iframe src='" .htmlentities($url) .'?col=' .urlencode($col) .'&search=' .urlencode($search) .'&limit=' .urlencode($limit) .'&page=' .urlencode($i) ."'></iframe><br>";


Attempt 5 (opens to page with no search results shown as if no params in url)

$i = 1;
$url2 = "http://localhost/test/pagination_2.php?col=$col&search=$search&limit=$limit&page=$i";

echo "<iframe src='" .htmlentities($url2) .urlencode($url2) ."'></iframe><br>";
Copy linkTweet thisAlerts:
@developer_webauthorNov 03.2020 — @Sempervivum,


Did I ask you before if you know about iFrames or was it cookies you said you got no experience in ?
Copy linkTweet thisAlerts:
@developer_webauthorNov 10.2020 — It seems iFrame fails to open to a url that got var values in the url. How to convert the url to constant after getting the var value ?

So, if url is:

domain.com/pagination.php?search=$domain&tbl=$tbl&col=$col&page=$page

And,

$domain = heman.com

$tbl = links

$col = keywords

$page = 1

then iFrame should open to:

domain.com/pagination.php?search=heman.com&tbl=links&col=keywords&page=1

That is what I want.
Copy linkTweet thisAlerts:
@developer_webauthorNov 11.2020 — Anyone got a clue what is wrong ?
Copy linkTweet thisAlerts:
@developer_webauthorNov 19.2020 — @NogDog

Do you mind chiming in ?
×

Success!

Help @developer_web spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...