Jump to content

Text Box help


JasperHope

Recommended Posts

Can someone please take a look at this code and try to see what's wrong with it?

 

You use the first file to input text. It then requests the process of the second file to save the data to a .txt file.1

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Cross-Browser Rich Text Editor (RTE)</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="keywords" content="cross-browser rich text editor, rte, textarea, htmlarea, content management, cms, blog, internet explorer, firefox, safari, opera, netscape, konqueror" />
<meta name="description" content="The cross-browser rich-text editor (RTE) is based on the designMode() functionality introduced in Internet Explorer 5, and implemented in Mozilla 1.3+ using the Mozilla Rich Text Editing API." />
<meta name="author" content="Kevin Roth" />
<meta name="ROBOTS" content="ALL" />
<!-- html2xhtml.js written by Jacob Lee <[email protected]> //-->
<script language="JavaScript" type="text/javascript" src="../cbrte/html2xhtml.js"></script>
<script language="JavaScript" type="text/javascript" src="../cbrte/richtext_compressed.js"></script>
</head>
<body>

<h2>Cross-Browser Rich Text Editor (RTE) Demo</h2>
<p>For more information, visit the <a href="http://www.kevinroth.com/rte/">Cross-Browser Rich Text Editor (RTE) home page</a>.</p>

<!-- START Demo Code -->
<form name="RTEDemo" action="../blog/save.php" method="POST" onsubmit="return submitForm();">

<script language="JavaScript" type="text/javascript">
<!--
function submitForm() {
//make sure hidden and iframe values are in sync for all rtes before submitting form
updateRTEs();

return true;
}

//Usage: initRTE(imagesPath, includesPath, cssFile, genXHTML, encHTML)
initRTE("../cbrte/images/", "../cbrte/", "", true);
//-->
</script>
<noscript><p><b>Javascript must be enabled to use this form.</b></p></noscript>

<script language="JavaScript" type="text/javascript">
<!--
//build new richTextEditor
var rte1 = new richTextEditor('rte1');
<?php
//format content for preloading
if (!(isset($_POST["rte1"]))) {
$content = "here's the " . chr(13) . "\"preloaded <b>content</b>\"";
$content = rteSafe($content);
} else {
//retrieve posted value
$content = rteSafe($_POST["rte1"]);
}
?>
rte1.html = '<?=$content;?>';
//rte1.toggleSrc = false;
rte1.build();
//-->
</script>
<p><input type="submit" name="submit" value="Save" /></p>
</form>
<?php
function rteSafe($strText) {
//returns safe code for preloading in the RTE
$tmpString = $strText;

//convert all types of single quotes
$tmpString = str_replace(chr(145), chr(39), $tmpString);
$tmpString = str_replace(chr(146), chr(39), $tmpString);
$tmpString = str_replace("'", "&#39;", $tmpString);

//convert all types of double quotes
$tmpString = str_replace(chr(147), chr(34), $tmpString);
$tmpString = str_replace(chr(148), chr(34), $tmpString);
//	$tmpString = str_replace("\"", "\"", $tmpString);

//replace carriage returns & line feeds
$tmpString = str_replace(chr(10), " ", $tmpString);
$tmpString = str_replace(chr(13), " ", $tmpString);

return $tmpString;
}
?>
<!-- END Demo Code -->

</body>
</html>

<? 
$content = $_POST['submit']; 
$file = "../blog/file.txt"; 
$Saved_File = fopen($file, 'w'); 
fwrite($Saved_File, $content); 
fclose($file); 
?> 

<script language=javascript> 
<!-- 
history.back(); 
--> 
</script> 

 

Link to comment
https://forums.phpfreaks.com/topic/198909-text-box-help/
Share on other sites

I'll try to simplify it a bit.

 

This code works:

<form action="../blog/save.php" method="POST"> 
<textarea name="content"></textarea> 
<br> 
<input type="submit" value="Save"> 
</form> 

 

And this code doesn't. It has been heavily modified to use a rich text editor:

<form name="RTEDemo" action="../blog/blog_entries.php" method="POST" onsubmit="return submitForm();">
<div align="center">
  <script language="JavaScript" type="text/javascript">
<!--
function submitForm() {
//make sure hidden and iframe values are in sync for all rtes before submitting form
updateRTEs();

//change the following line to true to submit form
alert("rte1 = " + (document.RTEDemo.rte1.value));
return false;
}

//Usage: initRTE(imagesPath, includesPath, cssFile, genXHTML, encHTML)
initRTE("../cbrte/images/", "../cbrte/", "", true);
//-->
</script>
  <noscript>
  <p><b>Javascript must be enabled to use this form.</b></p>
  </noscript>
  
  <script language="JavaScript" type="text/javascript">
<!--
//build new richTextEditor
var rte1 = new richTextEditor('rte1');
rte1.html = 'here&#39;s the "\<em\>preloaded\<\/em\> \<b\>content\<\/b\>"';

//enable all commands for demo
rte1.cmdFormatBlock = true;
rte1.cmdFontName = true;
rte1.cmdFontSize = true;
rte1.cmdIncreaseFontSize = true;
rte1.cmdDecreaseFontSize = true;

rte1.cmdBold = true;
rte1.cmdItalic = true;
rte1.cmdUnderline = true;
rte1.cmdStrikethrough = true;
rte1.cmdSuperscript = true;
rte1.cmdSubscript = true;

rte1.cmdJustifyLeft = true;
rte1.cmdJustifyCenter = true;
rte1.cmdJustifyRight = true;
rte1.cmdJustifyFull = true;

rte1.cmdInsertHorizontalRule = true;
rte1.cmdInsertOrderedList = true;
rte1.cmdInsertUnorderedList = true;

rte1.cmdOutdent = true;
rte1.cmdIndent = true;
rte1.cmdForeColor = true;
rte1.cmdHiliteColor = true;
rte1.cmdInsertLink = true;
rte1.cmdInsertImage = true;
rte1.cmdInsertSpecialChars = true;
rte1.cmdInsertTable = true;
rte1.cmdSpellcheck = true;

rte1.cmdCut = true;
rte1.cmdCopy = true;
rte1.cmdPaste = true;
rte1.cmdUndo = true;
rte1.cmdRedo = true;
rte1.cmdRemoveFormat = true;
rte1.cmdUnlink = true;

rte1.toggleSrc = true;

rte1.build();
//-->
</script>
</div>
<p align="center">Click submit to complete the update.</p>
<p align="center"><input type="submit" name="submit" value="Save" /></p>
</form>

 

Please help! I've tried everything I can think of.

Link to comment
https://forums.phpfreaks.com/topic/198909-text-box-help/#findComment-1044106
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.