{"id":16686,"date":"2015-08-19T05:01:07","date_gmt":"2015-08-18T19:01:07","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=16686"},"modified":"2024-11-07T11:03:11","modified_gmt":"2024-11-07T01:03:11","slug":"php-content-type-iframe-overlay-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/php-content-type-iframe-overlay-tutorial\/","title":{"rendered":"PHP Content Type Iframe Overlay Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/php_content_type.php\" rel=\"noopener\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"PHP Content Type Iframe Overlay Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/php_ct.gif\" title=\"PHP Content Type Iframe Overlay Tutorial\" id='misi' onmouseover=\" this.src=this.src.replace('.gif', '.xpng').replace('.png', '.xgif').replace('.x', '.'); \" \/><\/a><p class=\"wp-caption-text\">PHP Content Type Iframe Overlay Tutorial<\/p><\/div>\n<p>Today we drill deeper into the scenario 3 of yesterday&#8217;s <a target=\"_blank\" title='PHP Content Type Primer Tutorial' href='#pcrpt' rel=\"noopener\">PHP Content Type Primer Tutorial<\/a> as shown below.<\/p>\n<p>In the process we discover another concept for the <a target=\"_blank\" title='Blog postings with tag of overlay' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/overlay' rel=\"noopener\">&#8220;overlay&#8221;<\/a> ideas we present at this blog.  It is not that we haven&#8217;t done this before, in a sense, but that we haven&#8217;t tagged it as an idea in the category (or &#8220;tag&#8221; (chortle, chortle)) of &#8220;overlay&#8221;, but we need to talk about it &#8230; you first &#8230; ooooookay &#8230; an HTML <a target=\"_blank\" title='HTML iframe information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_iframe.asp' rel=\"noopener\">iframe<\/a> element that has its src= parameter be dynamically changed is another way to think of a concept of &#8220;overlay&#8221; &#8230; okay, it&#8217;s out there &#8230; do with it what you will!   Call up the president on the red phone, or pick the yellow phone and speak to your <a target=\"_blank\" title='?' href='http:\/\/www.youtube.com\/watch?v=66IWgU9AAis' rel=\"noopener\">Avon<\/a> representative.<\/p>\n<p>But, seriously, this is serious &#8230; can&#8217;t you tell?!<\/p>\n<p>What we want to point out about that src= value to dynamically change is that it can be like yesterday&#8217;s call with a PHP content type (or mime type) that is not your usual &#8220;text\/html&#8221;.  Is THIS of more interest now?!<\/p>\n<p>But, seriously, this is serious &#8230; you can tell &#8230; <font size=1>we changed the font size<\/font> &#8230; now <font size=4>THAT<\/font>&#8216;s <font size=3>serious<\/font>.<\/p>\n<p>The upshot is, that this may mean you can synchronize media perhaps (and perhaps you were a reader when we did tutorials like <a target=\"_blank\" title='PHP\/Javascript Media Synchronize Cross Browser Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/phpjavascript-media-synchronize-cross-browser-tutorial\/' rel=\"noopener\">PHP\/Javascript Media Synchronize Cross Browser Tutorial<\/a> (which attempted synchronization of media) earlier at this blog), or what we do today with our <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/php_ct.gif\" title='tutorial picture' rel=\"noopener\">tutorial picture<\/a>, and allow for the piecing together of a &#8220;home cobbled&#8221; slideshow, a common overlay &#8220;suspect&#8221;.  We allow for the &#8220;Add&#8221; option rather than &#8220;Overlay&#8221; as well, to open up a new HTML iframe on the fly, so to speak.<\/p>\n<p>If you ever use the wonderful <a target=\"_blank\" title='Gifpal website can create animated GIFs' href='http:\/\/www.gifpal.com' rel=\"noopener\">Gifpal<\/a> to create your animated GIFs, we hope to have achieved something just a tad similar, in that, once you enter in a new URL, it is added into the slideshow dynamically, probably not as cutely as Gifpal, but there&#8217;s an element of cuteness to seeing a slideshow presentation dynamically change &#8230; or it could be that the writer is easily amused!<\/p>\n<p>So have a go at a <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/php_content_type.php\" title='Click picture' rel=\"noopener\">live run<\/a> if you like, or take a gecko at the PHP source code you could call <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/php_content_type.php-GETME\" title=\"php_content_type.php\" rel=\"noopener\">php_content_type.php<\/a> or take a squizz at the changes made to yesterday&#8217;s efforts at <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/php_content_type.php-GETME\" title=\"php_content_type.php\" rel=\"noopener\">php_content_type.php<\/a><\/p>\n<hr>\n<p id='pcrpt'>Previous relevant <a target=\"_blank\" title='PHP Content Type Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/php-content-type-primer-tutorial\/' rel=\"noopener\">PHP Content Type Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/php_content_type.php\" rel=\"noopener\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"PHP Content Type Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/php_ct.jpg\" title=\"PHP Content Type Primer Tutorial\" \/><\/a><p class=\"wp-caption-text\">PHP Content Type Primer Tutorial<\/p><\/div>\n<p>Today we want to start a discussion on a big topic in web programming, the webpage content type (or <a target=\"_blank\" title='MIME information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/MIME' rel=\"noopener\">mime type<\/a>).<\/p>\n<p>The normal association of webpages is with the &#8230;<\/p>\n<p><code><br \/>\ntext\/html<br \/>\n<\/code><\/p>\n<p> &#8230; mime type.  Server side languages such as PHP and ASP.Net, for the most part, create webpages in HTML format, but they don&#8217;t have to.  Supposing you have some PDF data then you can use PHP&#8217;s header method to use (the snippet from today&#8217;s PHP <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/php_content_type.php_GETME\" title=\"php_content_type.php\" rel=\"noopener\">php_content_type.php<\/a>) &#8230;<\/p>\n<p><code><br \/>\n&lt;?php<br \/>\n\/\/ ...<br \/>\n\/\/ no echo statements anywhere up here<br \/>\n\/\/ ...<br \/>\n        <a target=\"_blank\" title='PHP header method information' href='http:\/\/php.net\/manual\/en\/function.header.php' rel=\"noopener\">header<\/a>('Content-Type: ' . $ct);<br \/>\n        echo <a target=\"_blank\" title='PHP file_get_contents method information' href='http:\/\/php.net\/manual\/en\/function.file-get-contents.php' rel=\"noopener\">file_get_contents<\/a>(<a target=\"_blank\" title='PHP urldecode method information' href='http:\/\/php.net\/manual\/en\/function.urldecode.php' rel=\"noopener\">urldecode<\/a>($_POST['selname']));<br \/>\n?&gt;<br \/>\n<\/code><\/p>\n<p> &#8230; to show a webpage using a mime type defined by the PHP variable $ct which is &#8220;application\/pdf&#8221; in the URL &#8220;http:\/\/localhost:888\/logo.pdf&#8221; of our example <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/php_ct.jpg\" rel=\"noopener\">tutorial picture<\/a>.<\/p>\n<p>We show this distinction today by writing a PHP web application that in the first instance is a web page consisting of an HTML form as per &#8230;<\/p>\n<p><code><br \/>\n&lt;form target='_blank' action='.\/php_content_type.php' method='POST'&gt;<br \/>\n...<br \/>\n<\/code><\/p>\n<p> &#8230; the &#8220;target=&#8217;_blank'&#8221; of which is ensuring a new webpage will be opened and by saying &#8220;method=&#8217;POST'&#8221;, on submission, would POST (into $_POST[&#8216;selname&#8217;]) to itself (in a new webpage) the HTML input type=url as per &#8230;<\/p>\n<p><code><br \/>\nUrl: &lt;input <a target=\"_blank\" title='input type=url information from w3schools' href='http:\/\/www.w3schools.com\/html\/html_form_input_types.asp' rel=\"noopener\">type='url'<\/a> name='selname' id='selname' style='width:70%;' value='http:\/\/www.rjmprogramming.com.au\/MyBusinessUnidad\/Welcome_files\/logo.jpg'&gt;&lt;\/input&gt;<br \/>\n...<br \/>\n<\/code><\/p>\n<p> &#8230; the user defined URL of interest.<\/p>\n<p>In the second instance, or the <a target=\"_blank\" title='Callback information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Callback_%28computer_programming%29' rel=\"noopener\">callback<\/a> scenario, the <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/php_content_type.php_GETME\" title=\"php_content_type.php\" rel=\"noopener\">php_content_type.php<\/a> code analyzes $_POST[&#8216;selname&#8217;] to derive a file extension (if none, would assume a mime type of text\/html).  That file extension we map against the very useful <a target=\"_blank\" title='Useful sitepoint webpage mime type list resource ... thanks heaps' href='http:\/\/www.sitepoint.com\/web-foundations\/mime-types-complete-list\/' rel=\"noopener\">sitepoint<\/a> resource we thank very much to arrive at a suitable mime type to be suitable for that PHP $ct variable we talked about earlier.  This gives us the scenario used for the middle of three buttons &#8230;<\/p>\n<ol>\n<li>Navigate via Web Browser &#8230; up at the web browser address bar you&#8217;ll see the Url of your data source<\/li>\n<li>Show via PHP Content Type to New Webpage &#8230; up at the web browser address bar you&#8217;ll see the Url of php_content_type.php (which got POSTed to &#8230; so no $_SERVER[&#8216;QUERY_STRING&#8217;] even)<\/li>\n<li>Show PHP Content Type Below &#8230; ie. to an HTML <a target=\"_blank\" title='HTML iframe information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_iframe.asp' rel=\"noopener\">iframe<\/a>, the scenario of today&#8217;s <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/php_ct.jpg\" rel=\"noopener\">tutorial picture<\/a><\/li>\n<\/ol>\n<p>With scenarios 2 and 3 above there is no hope that View-&gt;Page Source nor This Frame-&gt;View Page Source will result in a happy readable result, where scenario 1 will sometimes allow for this.<\/p>\n<p>With this knowledge in mind, or by trying a <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/php_content_type.php\" title='Live run' rel=\"noopener\">live run<\/a>, maybe now, some of the mystifying address bar URLs you encounter surfing the net may be more explainable to you &#8230; hope so.  Understanding of this topic can be a &#8220;light bulb&#8221; moment for many people, and a little bit of patience can reveal many possibilities with web applications, should you delve deeper yourself.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d16658' onclick='var dv=document.getElementById(\"d16658\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/?tag=text-widget\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d16658' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d16686' onclick='var dv=document.getElementById(\"d16686\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/?tag=php\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d16686' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Today we drill deeper into the scenario 3 of yesterday&#8217;s PHP Content Type Primer Tutorial as shown below. In the process we discover another concept for the &#8220;overlay&#8221; ideas we present at this blog. It is not that we haven&#8217;t &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/php-content-type-iframe-overlay-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,12,37],"tags":[1669,84,1667,576,587,590,760,792,1668,894,932,997,1151,1670,1319,1345,1404],"class_list":["post-16686","post","type-post","status-publish","format-standard","hentry","category-animation","category-elearning","category-tutorials","tag-address-bar","tag-animation-2","tag-content-type","tag-html","tag-iframe","tag-image","tag-media","tag-mime","tag-mime-type","tag-overlay","tag-php","tag-programming","tag-slideshow","tag-synchronize","tag-tutorial","tag-url","tag-web-browser"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/16686"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=16686"}],"version-history":[{"count":11,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/16686\/revisions"}],"predecessor-version":[{"id":65500,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/16686\/revisions\/65500"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=16686"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=16686"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=16686"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}