I building a cms of a site, and its nearly done! I have one problem i cant work out: I have a WYSIWYG editor that writes to a file: <form action="main.php" method="post"> <textarea name="main" id="main"><? include ('/home/2345/public_html/11/22/main.txt') ?></textarea> <script language="JavaScript"> generate_wysiwyg('main'); </script> <br /> <br /> <input type="submit" value="Confirm Changes"> </form> PHP: It then writes to main.php: <?php if (isset( $_POST )) $postArray = &$_POST ; // 4.1.0 or later else $postArray = &$HTTP_POST_VARS ; // prior to 4.1.0 $fname="/home/2345/public_html/11/22/main.txt"; if($nfile != false) { foreach ($postArray as $sForm => $value ) { if (get_magic_quotes_gpc()) { fwrite ($nfile, stripslashes($value)); } else { fwrite ($nfile, $value); } fclose($nfile); } } ?> PHP: Now that works ok for text, but it has to accept a php include linking to another site, but it outputs the include (<? include ('file.php') ?>) as text, not as php. Anyone know what im doing wrong? Thanks for your help
you have to use eval when you are reading it so that it reads the string as php and not text... soo something like... $file = file_get_contents("file.txt"); eval($file); should work, the thing is with eval is that, you dont use the open and close tags you just type whatever code you want
where would i place that? in the page i want to show the file or in one of the code snippets i posted above? thanks
its a really trustworthy organization it is for, so there will be no issues I still cant get it to display
That can be, but just note that it could be dangerous I don't say anyone WILL do such things, especially not the administrators of the script (only admins have access to this WYSIWYG, right?). Good luck!