/    Sign up×
Community /Pin to ProfileBookmark

Display seperate HTML page with php

I’m looking to have a page with a big text box on the left, and a window on the right. For the text box, PHP grabs the contents of a file, and puts the text into the box. Not all that hard. But I need to have a submit button which takes the value of the text box, and posts it to the page, and then the page takes that text and shows it in the window on the right. Still, not hard. Now, I need it to show the text submitted from the text box, in the window, as a web page. So it’s like a frame, that shows the web page you typed into the text box.
If you have no clue what i’m talking about take a look at [URL=http://www.w3schools.com/css/tryit.asp?filename=trycss_background-color]this.[/URL]
I want to make that in PHP. Does anyone have any suggestions where I might start?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@bokehAug 13.2006 — Like this:[code=php]<?php

$default = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'.
"n<html>n<head>n<title>Untitled</title>n</head>n<body>nn</body>n</html>";

if(isset($_POST['submit']))
{
die(get_magic_quotes_gpc() ? stripslashes($_POST['code']) : $_POST['code']);
}
elseif(isset($_GET['iframe']))
{
die($default);
}

?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
</head>
<body>

<form action="" method="post" target="my_iframe">
<p><input name="submit" type="submit" value="Edit the mark up and click me"></p>
<p><textarea name="code" rows="20" cols="40"><?php echo htmlspecialchars($default) ?></textarea></p>
</form>

<iframe name="my_iframe" src="<?php echo $_SERVER['PHP_SELF'] ?>?iframe"></iframe>

</body>
</html>[/code]
Copy linkTweet thisAlerts:
@AmazingAntauthorAug 13.2006 — Nice bit of code there. Thanks!
×

Success!

Help @AmazingAnt 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

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