Hi everybody
I have a php script which prints the output in an iframe, and I would like to have an area (iframe,texarea,layer etc) just below the iframe which will print the html source of this output. I need urgent help with this. I am totally lost.
I am thinking of using
echo htmlspecialchars($myhtmlcode) within <pre> </pre> tags.
But since php generates the hmtl and shows it in iframe I don't know how to create the variable $myhtmlcode?
Here's a test page I have created:
http://www.freeauctionscripts.com/example.php
And here's the code of this page:
THANK YOU IN ADVANCE
Matt

<html>
<body>
<?php
if ($submit) {

// set variables from form input 
    $f1 = $_POST['f1']; 
	echo "PHP Generates form output and print in this Iframe";
	echo "\n";
	echo $f1;
	}
	else {
?>

<table width="756" height="185" border="0">
  <tr>
    <td><form method="post" action="<?php echo $PHP_SELF?>" target="thumbnails" name="form">
        <table width="747" border="1">
          <tr> 
            <td width="342">FORM<br>
              <input name="f1" type="text" id="f1" /> <br> <input type="submit" name="submit" value="Submit"> 
            </td>
            <td width="395"> <iframe name=thumbnails width=395 height=420 frameborder=1 scrolling=auto>No 
              i-frames</iframe> </td>
          </tr>
          <tr> 
            <td> </td>
            <td>This is where I would like to print the html source of IFRAME which was generated by the form</td>
          </tr>
        </table>
      </form>
<?php
}
?>
	  </td>
  </tr>
</table>
</body>
</html>

    using the src (source) option of iframe you can read the content of the iframe from a html file... that file can be written by php

    can help you ?

      If you have checked the website link I have sent, you will see the form and iframe are in the same page. What I do is, I choose form's target as Iframe's name which is "thumbnails". So there is not another page to call within Iframe source. Do you have any ideas how to work this out. I am totally lost about this.
      Thanks for your help
      Matt

        If the point is showing a text in a frame, and its html code in another frame, on the same page: try this:

        Give a name to the frame on your example where is the

        "This is where I would like to print the html source of IFRAME which was generated by the form"

        using f.i. (html):

        <div id="viewhtml"></div>

        then you can get the html code of your iframe 'thumbnails' and use it (after a simple transformation) in this element 'viewhtml', using (html):

        document.getElementById("viewhtml").innerHTML = replace(getIFrameDocument("thumbnails").body.innerHTML,"<","&lt;")

          Thank you so much for the help. I need little bit clarification. Here's the actual page I am working on.
          http://www.freeauctionscripts.com/crosspromotion/
          So please let me know if I understand it right:
          I have an iframe just below the options as you see on the page which is named "thumbnails". When form is submitted it shows in this iframe (form target is "thumbnails).
          So let's say just below this iframe do you tell me to write;

          <div id="viewhtml">
              <?php
                 document.getElementById("viewhtml").innerHTML = replace    (getIFrameDocument("thumbnails").body.innerHTML,"<","&lt;");
               ?>						
          </div>
          

          And also I have added my menu to the page which uses include;

          <?php include "../menu.inc"?>

          And when you click submit it shows the menu in iframe too instead of only form results since form action is phpself.
          Do you have any idea also how to solve this?
          I have asked too many questions, I am sorry but I am a newbie and I have to finish this script as soon as I can, and I really appreciate your help.
          Thank you in advance
          Matt

            I gave you two pieces of code:

            1) a div-tagged code to name an html element of your webpage 'viewhtml': this is html code

            2) a javascript code to get the html source of the iframe 'thumbnails' and assign it to the html element 'viewhtml'

            this second piece of code can be run at client level, so you don't need any php script (run at server side) to get the html source

            isn't that your request?
            if not, go back to the first suggestion (iframe's src option)

            now, you could have:
            1) a html form is shown to the user : he fills the form and clicks the submit button
            2) some action is performed at client level , using javascript, including the generation of a new text in some frame of the same page
            3) the html source of that new text is taken (using the code I gave you) and shown in another frame of the same page

            (please tell me problem to discuss and solve, not send me code to test)

              Thank you for your patience. I am not clear about sth. let me ask.
              My page's name is "index.php"
              I have an iframe named "thumbnails"
              Where do I put div code? (in the form somewhere like this?)
              <div id="viewhtml"></div>
              and how do I use this javascript
              Do I have to add onsubmit=.... at the form? I don't know where to use
              document.getElementById("viewhtml").innerHTML = replace(getIFrameDocument("thumbnails").body.innerHTML,"<","&lt;")
              But I know this is what I am looking for, and it will solve my problem if you can tell me where to use it?
              Thank you again.
              Matt

                kirtok, here is what I understood about your intention, and two solution schemas, where what we discussed before is applied:

                fact 1)
                you DO have a php script generating the text in the first iframe, so that php script can easily generate the html source of the same text for the second iframe (NO need of javascript code to have that result)

                fact 2)
                you started using iframes
                some browsers don't support them, you know, but they help in building a fixed layout for the webpage
                again, iframe requires the content is available through another web address, by definition

                then,
                solution 1 - don't use iframes, have a layout not fixed

                <html>
                <body>
                <?php
                if ($submit) {
                   $f1 = $_POST['f1'];
                   $f1 = "<table><tr><td width=50%>".$f1."</td><td width=50%>this is a html text generated by php, based on the user selection</td></tr></table>";  
                $f1htm = str_replace("<","&lt;",$f1); } else { $f1="Here something will be displayed based on the user selection"; $f1htm="Here will be the html source of what displayed above"; } ?> <table width="756" height="185" border="0"> <tr> <td><form method="post" action="<?php echo $PHP_SELF?>" name="form"> <table width="747" border="1"> <tr> <td width="342">FORM<br> <input name="f1" type="text" id="f1" /> <br> <input type="submit" name="submit" value="Submit"> </td> <td width="395"><?php echo $f1 ?> </td> </tr> <tr> <td> </td> <td width="395"><?php echo $f1htm ?> </td> </tr> </table> </form> </td> </tr> </table> </body> </html>

                alternatively, solution 2) use iframes, use only one php script
                (the php script is used to generate 'on-the-fly' the iframe bodies)

                <html>
                <body>
                <?php
                //in this solution the generation of the webpage requires 3 calls to this php script
                //one to generate the global page and one for each iframe included
                //this script is able to manage some post and get vars
                //[post] f1 : the user choice (used generating the global page)
                //[get] s : the user choice (used generating the iframe bodies)
                //[get] m : the iframe the body is being generated for
                
                if ($_GET['m'] == '')  {   //generate the global page
                   if ($submit) $f1 = $_POST['f1'];      
                if ($f1=="") $f1="null"; //make f1 having a not null value ever //the user choice is now a php var and will be used in the html below //to compose a new call to this php script passing the choice as get var } else { //generate a html body to be displayed in the single iframe $f1 = $_GET['s']; if ($f1=="null") { //no user choice if ($_GET['m']=='thumbnails') $s="Here something will be displayed based on the user selection. At the moment the selection is null."; else $s="Here will be the html source of what displayed above"; } else { //user choise not null $s = "<table><tr><td width=50%>".$f1."</td><td width=50%>this is a html text generated by php, based on the parameters set in the form</td></tr></table>";
                if ($_GET['m']=='viewhtml') $s=str_replace("<","&lt;",$s); } echo $s; exit; } //the following html to be used to generate the global page only //both the two iframes require a new call to this php script ?> <table width="756" border="0"> <tr> <td><form method="post" action="<?php echo $PHP_SELF?>" name="form"> <table width="747" border="1"> <tr> <td width="342">FORM<br> <input name="f1" type="text" id="f1" /> <br> <input type="submit" name="submit" value="Submit"> </td> <td width="395"> <iframe name=thumbnails width=395 height=420 frameborder=1 scrolling=auto src="<?php echo $PHP_SELF.'?s='.$f1.'&m=thumbnails' ?>">No i-frames</iframe> </td> </tr> <tr> <td> </td> <td width="395"> <iframe name=viewhtml width=395 height=80 frameborder=1 scrolling=auto src="<?php echo $PHP_SELF.'?s='.$f1.'&m=viewhtml' ?>">No i-frames</iframe> </td> </tr> </table> </form> </td> </tr> </table> </body> </html>

                I suggest to keep it simple, separating the php script generating the webpage from that generating the iframe bodies...
                but first of all, I suggest not to use iframes

                  Jville thank you so much for taking your time and writing the code. I understood the whole concept. I am not going to use frames. But my real php script is little bit more complicated. Can you tell me how can I do that with this script?

                  <?php
                  //Copyright KIRTOK//
                  
                  // if submit pressed, then start processing form
                  if ($submit) {
                  
                  // set variables from form input 
                      $twidth = $_POST['twidth']; 
                      $theight = $_POST['theight']; 
                  	$target = $_POST['target']; 
                  	$rows = $_POST['rows'];
                  	$border = $_POST['border'];
                  	$thumbborder = $_POST['thumbborder'];
                  	$font = $_POST['font'];
                  	$fontsize = $_POST['fontsize'];
                  	$fontcolor = $_POST['fontcolor'];
                  	$title = $_POST['title'];
                  	$font2 = $_POST['font2'];
                  	$fontsize2 = $_POST['fontsize2'];
                  	$fontcolor2 = $_POST['fontcolor2'];
                  	$footer = $_POST['footer'];
                  	$storeurl = $_POST['storeurl'];
                  	$f[0] = $_POST['f1'];
                  	$f[1] = $_POST['f2']; 
                  	$f[2]= $_POST['f3'];
                  	$f[3]= $_POST['f4'];
                  	$f[4]= $_POST['f5'];
                  	$f[5]= $_POST['f6'];
                  	$f[6]= $_POST['f7'];
                  	$f[7]= $_POST['f8'];
                  	$f[8]= $_POST['f9'];
                  	$f[9]= $_POST['f10'];
                  	$imglink = "http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=";
                  	$imgsrc = "http://thumbs.ebay.com/pict/";
                  	$storeurl = $_POST['storeurl'];
                  	$jpg=".jpg";
                  //set counter to ten	
                  	$c = 0; 
                  echo "<table align=\"center\"><tr><td><font color=\"$fontcolor\" size=\"$fontsize\" face=\"$font\"><center>$title</center></font></td></tr></table>";	
                  //Start creating table
                  echo "<table border=\"$border\" align=\"center\">";
                  
                  echo "<tr>";
                  
                  
                  //Start do while
                  do
                  {
                  
                  $totalauctions = $c + 1;
                  $result = $totalauctions % $rows;
                  //Start if/break to check empty fields. If input field is empty,then jump out of do/while.
                  if  ($f[$c] =="") 
                  {
                  break;
                  }//End if/break
                  
                  if ($totalauctions <= $rows) {
                  echo "<td width=\"$twidth\" height=\"theight\"><a href=\"$imglink$f[$c]\" target=\"$target\"><img src=\"$imgsrc$f[$c].jpg\" width=\"$twidth\" height=\"$theight\" border=\"$thumbborder\"></a></td>";
                  
                  }
                  elseif ($result != 1) {
                  echo "<td width=\"$twidth\" height=\"theight\"><a href=\"$imglink$f[$c]\" target=\"$target\"><img src=\"$imgsrc$f[$c].jpg\" width=\"$twidth\" height=\"$theight\" border=\"$thumbborder\"></a></td>";
                  } 
                  else {
                  echo "<tr>";
                  
                  //Create column
                  echo "<td width=\"$twidth\" height=\"theight\"><a href=\"$imglink$f[$c]\" target=\"$target\"><img src=\"$imgsrc$f[$c].jpg\" width=\"$twidth\" height=\"$theight\" border=\"$thumbborder\"></a></td>";
                  
                  //End row
                  
                  
                  }
                  
                  $c = $c + 1;
                  }
                  while ( $c <= 10 ) ;
                  
                  
                  //Checks 10 times within do while loop
                  echo "</table>"; 
                  echo "<table align=\"center\"><tr><td><font color=\"$fontcolor2\" size=\"$fontsize2\" face=\"$font2\"><center>$footer</center></font></td></tr></table>";
                  echo "<table align=\"center\"><tr><td><font color=\"$fontcolor2\" size=\"$fontsize2\" face=\"$font2\"><center>Please also visit our <a href=\"$storeurl\" target=\"$target\">Ebay Store</a> </center></font></td></tr></table>";
                  }
                  else {
                  
                    Write a Reply...