I have two pages, both extremely simple. One of the has some code on it which is literally an iframe with some basic CMS controls which allows the user to enter some text in it (by default it reads some pre-written text from a file and pastes it into the iframe).

if (isset($_SESSION['logged_in']) != true) {
    header('Location: login.php?ermess=logout');
echo "<?xml version='1.0' encoding='UTF-8'?>";

$_SESSION['pagename'] = $_GET['pagename'];

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

    <link rel="stylesheet" type="text/css" href="cpanel.css" />


        <title>Page editor</title>
        <script type="Javascript" src="editor.js"></script>
        <form method="POST" action="saver.php">
                <input type="button" onclick="Colour('Green')" style="background-color:Green;" />
                <input type="button" onclick="Colour('Red')" style="background-color:Red;" />
                <input type="button" onclick="Colour('Blue')" style="background-color:Blue;" />
                <input type="button" onclick="Colour('Black')" style="background-color:Black;" />
                <input type="button" onclick="Format('bold')" value="B" />
                <input type="button" onclick="Format('italic')" value="I" />
                <input type="button" onclick="Format('Underline')" value="U" />
                <input type="button" onclick="Format('justifycenter')" value="C" />
                <input type="button" onclick="Format('justifyleft')" value="L" />
                <input type="button" onclick="Format('justifyright')" value="R" /><br/>

<?php echo "<iframe id='textbox' name='textbox' style='width:300px; height:150px'; src='../site/{$_GET['pagename']}'></iframe><br/>"; ?>

                <input type="submit" value="Save changes" />
                <input type="hidden" id="text" name="text" />


Then the user clicks Save, and the text from an iframe gets POSTed to another page, which is suposed to echo it, but doesn't.

<?php session_start();
if (isset($_SESSION['logged_in']) != true) {
    header('Location: login.php?ermess=logout');
echo "lol";
echo $_POST['text'];
echo $_POST['textbox'];


So - iframe, submit button, echo.

I went over and over the code and can't see why the text doesn't get posted... Any help would be greatly appreciated!

Edited by Lioshenka: n/a

6 Years
Discussion Span
Last Post by Lioshenka

The <iframe> is not a form element so you will not be able to transfer data from an Iframe through a $_POST or $_GET via the url. You will most probably have to use a <textarea> which is a form element in order to transfer data.

If you have to use a text box and transfer the code from the <iframe> to the textbox using Javascript using which you can then send the data through the POST.

Try this code.

<title>Shopping cart test</title>
function tryout(){
<form onsubmit="tryout()" action="#" method="post">
<iframe name="txtbox" id="txtbox" src="check_links.php">hi</iframe><br />
<input type="text" name="code" id="code" /> 
<input type="button" onclick="tryout()" value="Click" />
<input type="submit">

You can access the urldecode($_POST['code']) to get the code from the iframe.

All the best!!!

Edited by sudeepjd: n/a

Votes + Comments
Thanks for your help with PHP/JS
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.