I am trying to embed global session variables with url using iframe - php

I am trying to embed session variables to url that are set by another module in drupal 7.When i try to make an iframe the iframe works but my session variables are not embedded with url.
Any help will be much appreciated.i also checked sessions using devel modules session viewer they are shown there.
Here is the code that i am using in the iframe content type.
<iframe src="http://www.w3schools.com?"$_SESSION['name']""></iframe>

actully im not aware about drupal but i think this will work
<iframe src="http://www.w3schools.com?sname='"<?php echo $_SESSION['name']; ?>"'"></iframe>
please try this

$_SESSION['name'] shoud be
You need to add php code tag for php code.
Always use for dyanmic codde

i am not drupal developer but in this iframe php syntax is not proper. concatenation is missing .
<iframe src="http://www.w3schools.com?"<?php echo $_SESSION['name'];?>""></iframe>
please try this.

Related

captcha in smarty doesn't work

I have this problem with smarty, I tried to add a captcha in smarty but I can't see the way of make it work, basically the error comes when i try to show the captcha image, in a normal php file I could embed this php script:
<?php
$SampleCaptcha = new Captcha("SampleCaptcha");
$SampleCaptcha->UserInputID = "CaptchaCode";
echo $SampleCaptcha->Html();
?>
But for smarty I did this:
$SampleCaptcha = new Captcha("SampleCaptcha");
$SampleCaptcha->UserInputID = "CaptchaCode";
$captcha=$SampleCaptcha->Html();
$sy->assign('captcha', $captcha);
The think is that the variable captcha does print the whole html to show the captcha but when it prints the image attr src it does it in php still.
<img alt="CAPTCHA" src="botdetect.php?get=image&c=samplecaptcha&t=da491a96235a0d9f5fbeb0d7c0accc89" id="SampleCaptcha_CaptchaImage" class="LBD_CaptchaImage">
I tried to use a smarty plugin function but it does the same.
Any expert in smarty may know the answer.
Many thanks.
Try this.
It may help you as this site has good examples across different platforms.

Trying php to reload page

I am trying to use an image as a button to refresh pages on a website. The footer (a php include) is currently using this code to refresh each page:
<img src="/images/refresh.png">
which of course works. BUT I would like to improve it. Essentially, it would be something like this:
onClick="javascript: window.location.href='abcd.html';"
BUT I need it to work dynamically because I'm using php pages. So I was thinking this would work:
<img src="/images/refresh.png">
But it doesn't work. Any ideas? I'm using <? php $_SERVER['REQUEST_URI'] ?> wrong (obviously), so, any ideas for assistance? Thank you for any help!
Problem noticed is you have a space between <? and php in the following line:
<img src="/images/refresh.png">
Also you want to echo out the value for $_SERVER['REQUEST_URI']. You are just calling $_SERVER['REQUEST_URI']. Also as #NickCoons pointed out when using the echo construct you need to add a semi-colon i.e. echo $_SERVER['REQUEST_URI'];.
Try the following:
<img src="/images/refresh.png">

Iframe URL - PHP or Javascript?

I'm trying to build a custom top toolbar which an iframe below it.
Something similar to this:
http://themes.goodlayers.com/?theme=greenearth
I plan one using it on a blog, so i will be making posts linking to other sites. My question is what do i need to make a custom url function that so i just add it in front of the other site's url so that it shows up in an iframe.
For example:
I want to link to google in an iframe with my top toolbar above.
Is there a script that allows me to use a url like this:
http://www.mywebsite.com/frame.php?http://www.google.com/
Thanks for your time!
Iframes are always bad. Don't do it.
That said, with PHP, you can do this:
<iframe src="<? echo $_SERVER['QUERY_STRING'] ?>" />
You can also do something like mywebsite.com?url=google.com, and use $_GET['url'] instead.
Eg url: http://mywebsite.com/index.php?iframe=http://www.google.ro
PHP:
<?php
if ($_GET['iframe']) {
echo"<iframe src='".$_GET['iframe']"' width='200px' height='150px'>";
} ?>
I hope this will help you!

iframe GET url variable

I'm trying to give the users of my website the option to externally embed an html5 player , and in order to do that I thought of putting a value in the iframe's src by reading it from the parent page, then passing it as a variable in the php file which will be shown to the user.
Let's say that
$value_from_parent_page = "song1"
and parent page contains copy-able code for the users
<iframe src="http://example.com/load.php?embed='$value_from_parent_page'" ></iframe>
The load.php contains
<?php
$val  =  $_GET['embed'];
echo "<audio src='"$val".mp3'></audio>";
?>
The result has to be like
<audio src='song1.mp3'></audio>
Is it possible to work like that and is the code valid? (i apologise I don't have access to normal computer to test).
Thanks in advance.
This should work, and is valid, now the issue of using an iframe would be well, make sure that it is an iframe you need as there are probably better ways of going about this, but in your scenario i would say this is the best way to do it and valid for best cross platform support.

php open dynamic link in new window with iframe

Hello I am trying to figure out how to make it so when someone clicks a link on my search results it will open in a new window and in the new window have an iframe that displays the url. I am not sure how to go about doing this. I have
$row['url']
that displays the url for each result to use.
To be more specific I am trying to do what filestube does. I like the feature a lot and would like to use something like it on my site. Here is an example url to show you want I mean http://www.filestube.com/5a4c10249bd9fce003e9/go.html
when the link is clicked on filestube it will open a page like this. I have seen lots of sites do this but filestube is what pops in my head right now. Can anyone provide me with a code example or try to explain how to do this? thanks.
You need to redirect to a URL inside of your application, example my_url.php and post to it in parameters the URL you want to show. Than in that script, load an iFrame with that URL.
Example of my_url.php?url=http://www.google.ca:
<div>You Header</div>
<iframe src="<?php $_GET['url']"></iframe>
<div>Your Footer</div>
The link should point to another PHP page. Something like this.
http://www.google.com
In your open-link.php, write your iframe code.
<iframe src="<?=$_GET['url']?>"></iframe>
Assuming you have PHP file named external.php
Make that PHP file accept a $_GET parameter.
Pass the URL as a param
Use that URL to point the iframe in that PHP file to whatever URL is passed

Categories