Jump to content

[SOLVED] opposite function


Ninjakreborn

Recommended Posts

I am sitting here with something called RTE

 

It has a function

<?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;
}
?>

This is ok, it cleans the content before putting it "back" into the editor.  The problem I am having is that, they submit the form, it goes to another page, then comes back if they had errors, it cleans before loading content.  But it adds /n/r/n/r at the end of the description,e very single time.  I am doing my own server side cleaning.  I run it through strip tags with which ones I want to allow, as well as mysql real escape string, but this thing cuts it up before i have a change. Does anyone know of the "opposite" function I can run in the backend, to basically undo all the changes the above function made?

Link to comment
Share on other sites

It's going to be impossible to reverse the following two lines:

<?php
$tmpString = str_replace(chr(10), " ", $tmpString);
$tmpString = str_replace(chr(13), " ", $tmpString);
?>

 

Those lines are replacing both matching characters with a space. When you try to reverse that, there is no way to know which character to use to replace the spaces found. In addition, you don't want to replace all spaces with other character sets, either. This definitely looks like a one-way change to me.

Link to comment
Share on other sites

Yes, everything else works perfectly.  The quotes, single quotes work.  Extra characters aren't messed with.  It's only that it adds that damn

Description:

rn west test

 

This is a 'final' test to see how "things" go!!!

rnrn

It seems to throw those rnrn here and there, is there a way I can remove that atleast.

It handles everything else graciously, except for that one things.

Link to comment
Share on other sites

I don't know what's causing your carriage returns and/or line feeds. It's not that function, though. In fact, that function removes all of those characters with the lines I quoted above. If you'll check out the ASCII table, you'll see that carriage returns and line feeds are chr(10) and chr(13), and those are what are being replaced with spaces. So, your carriage returns have to be coming from somewhere else.

Link to comment
Share on other sites

I am very confused then.

Here is the text for the editor.
[code
<script language="JavaScript" type="text/javascript">
<!--
//build new richTextEditor
var rte1 = new richTextEditor('description');
<?php
$content = rteSafe($_SESSION['temp']['description']);
?>
rte1.html = '<?php echo $content; ?>';
rte1.toggleSrc = false;
rte1.build();
//-->
</script>

See that's the original text, then it get's passed to another page, which this is done on it.

 

	
<?php	
$allowedtags = "<br>, <ul>, <li>, <ol>, <b>, <strong>, <u>";
$_SESSION['temp']['description'] = strip_tags($_SESSION['temp']['description'],	$allowedtags);	
$_SESSION['temp']['description'] = mysql_real_escape_string($_SESSION['temp']['description']);
?>

 

That is all that is done to that variable.  Description is also the only variable it's happening to, it has to have something to do with it?

 

Maybe not any advice on what could be causing this, I never encountered this problem before.

Link to comment
Share on other sites

I am going to try that, but can you help me understand "why" it's doing that.

 

The problem I am having is, I have the form, I already did a test.

It's not originally coming from the form the first time.

It's not coming from me using the stiptags, or mysql_real_escape_string

It has something to do with the form but it doesn't always happen, I will try trim, hopefully it will work, but Ihope someone can tell me what is causing it for future problems like this in the future.

Link to comment
Share on other sites

I can't see anything with the PHP that can cause this. If the trim() doesn't help it means that there's a problem with something after the final result has been generated- such as with the Javascript or HTML in the second page. In this case, you'll need to investigate the output source.

If adding trim() does help, that means the problem is either with the PHP (and if it is- I have no clue what could be causing the problem) or with the HTML/Javascript in the form itself.

 

Orio.

Link to comment
Share on other sites

Form Page

<?php require_once(".@@@####")?>
<?php
if ($_SESSION['controller'] == true) {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php require_once($docroot . "/master/includes/meta.inc.php"); ?>
<script language="JavaScript" type="text/javascript" src="../rte/html2xhtml.js"></script>
<script language="JavaScript" type="text/javascript" src="../rte/richtext_compressed.js"></script>
<script language="JavaScript" type="text/javascript">
function toggleoff(offtarget1, offtarget2) {
document.getElementById(offtarget1).style.display='none';
document.getElementById(offtarget2).style.background='#FFFFFF';
}

function toggleon(ontarget1, ontarget2) {
document.getElementById(ontarget1).style.display='inline';	
document.getElementById(ontarget2).style.background='#CCCC99';
}
//-->
</script>
<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 = " + htmlDecode(document.RTEDemo.rte1.value));
return false;
}

//Usage: initRTE(imagesPath, includesPath, cssFile, genXHTML, encHTML)
initRTE("../rte/images/", "./", "", true);
//-->
</script>
<noscript><p><b>Javascript must be enabled to use this form.</b></p></noscript>
<?php
// this function is part of RTE
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 of the RTE related function
?>
</head>
<body id="safety">
<div id="logo"><p>Employee Safety Report</p></div>
<div id="safetydiv">
<div id="box">
Just text from the website goes here,.
</p>
<hr />
<form action="index2.php" method="post" name="submitform" id="submitform" onsubmit="return submitForm();">
<ul>
<li><input name="status"
<?php
if ($_SESSION['temp']['status'] == "fullidentity") {
echo "checked=\"checked\"";
}
?>
onclick="toggleon('hide1', 'name'); toggleon('hide2', 'title'); toggleon('hide3', 'phone'); toggleon('hide4', 'email');" id="fullidentity" value="fullidentity" type="radio" checked="checked" /><label for="status"><span class="bold">Full Identity</span> -  <span class="smalltext">I wish to receive feedback and correspond with Safety about this report.</span></label></li>
<li><input name="status" 
<?php
if ($_SESSION['temp']['status'] == "confidential") {
echo "checked=\"checked\"";
}
?>
onclick="toggleon('hide1', 'name'); toggleon('hide2', 'title'); toggleon('hide3', 'phone'); toggleon('hide4', 'email');" id="confidential" value="confidential" type="radio" /><label for="status"><span class="bold">Confidential</span> - <span class="smalltext">I would like this report to be confidential but also get feedback.</span></label></li>
<li><input name="status" 
<?php
if ($_SESSION['temp']['status'] == "anonymous") {
echo "checked=\"checked\"";
}
?>
onclick="toggleoff('hide1', 'name'); toggleoff('hide2', 'title'); toggleoff('hide3', 'phone'); toggleoff('hide4','email');"id="anonymous" value="anonymous" type="radio" /><label for="status"><span class="bold">Anonymous</span> -  <span class="smalltext">I wish to remain anonymous and only receive acknowledgement of submission.<br />                                              (email address must be provided for acknowledgement)</span></label></li>
</ul>
<br /><br />

	<table align="center">
	<tr>
	<td class="left"><label for="name">Name:</label></td>
	<td></td>
	<td class="right"><span class="red" id="hide1">*</span>
<input name="name" id="name" class="require" type="text" maxlength="200" value="<?php echo $_SESSION['temp']['name']; ?>" /></td>
	</tr>
	<tr>
	<td class="left"><label for="title">Job Title/Description:</label></td>
	<td></td>
	<td class="right"><span class="red" id="hide2">*</span>
<input name="title" id="title" class="require"  type="text" maxlength="200" value="<?php echo $_SESSION['temp']['title']; ?>" /></td>
	</tr>
	<tr>
	<td class="left"><label for="phone">Phone:</label></td>
	<td></td>
	<td class="right"><span class="red" id="hide3">*</span>
<input name="phone" id="phone" class="require"  type="text" maxlength="200" value="<?php echo $_SESSION['temp']['phone']; ?>" /></td>
	</tr>
	<tr>
	<td class="left"><label for="email">Email Address:</label></td>
	<td></td>
	<td class="right"><span class="red" id="hide4">*</span>
<input name="email" id="email" class="require" type="text" maxlength="200" value="<?php echo $_SESSION['temp']['email']; ?>" /></td>
	</tr>
	<tr>
	<td class="left"><label for="dateoccured">Date Occurred:</label></td>
	<td class="left"><input name="dateoccured_na" <?php 
										if ($_SESSION['temp']['dateoccured_na'] == 
										"Not Applicable") {
											echo "checked=\"checked\"";
										}
										?> id="dateoccured_na" type="checkbox" value="Not Applicable" /><label for="dateoccured_na">N/A</label></td>
	<td class="right"><?php
	$month = date("m"); // this traps the 2 digit day of the month in a variable
	?>
	<select class="safetydate" name="dateoccured1" id="dateoccured1">
	<option value="01" <?php 
	if (isset($_SESSION['temp']['dateoccured1'])) {
		tempvar($_SESSION['temp']['dateoccured1'], "01");
	}else {
		tempvar($month, "01");
	} 
	?>>January</option>

	<option value="02" <?php 
	if (isset($_SESSION['temp']['dateoccured1'])) {
		tempvar($_SESSION['temp']['dateoccured1'], "02");
	}else {
		tempvar($month, "02");
	}
	?>>February</option>
	<option value="03" <?php 
	if (isset($_SESSION['temp']['dateoccured1'])) {
		tempvar($_SESSION['temp']['dateoccured1'], "03");
	}else {
		tempvar($month, "03");	
	} 
	?>>March</option>
	<option value="04" <?php 
	if (isset($_SESSION['temp']['dateoccured1'])) {
		tempvar($_SESSION['temp']['dateoccured1'], "04");
	}else {
		tempvar($month, "04");
	}
	?>>April</option>
	<option value="05" <?php 
	if (isset($_SESSION['temp']['dateoccured1'])) {
		tempvar($_SESSION['temp']['dateoccured1'], "05");
	}else {
		tempvar($month, "05");
	}
	?>>May</option>
	<option value="06" <?php 
	if (isset($_SESSION['temp']['dateoccured1'])) {
		tempvar($_SESSION['temp']['dateoccured1'], "06");
	}else {
		tempvar($month, "06");
	}
	?>>June</option>
	<option value="07" <?php 
	if (isset($_SESSION['temp']['dateoccured1'])) {
		tempvar($_SESSION['temp']['dateoccured1'], "07");
	}else {
		tempvar($month, "07");
	}

	?>>July</option>
	<option value="08" <?php 
	if (isset($_SESSION['temp']['dateoccured1'])) {
		tempvar($_SESSION['temp']['dateoccured1'], "08");
	}else {
		tempvar($month, "08");
	}

	?>>August</option>
	<option value="09" <?php 
	if (isset($_SESSION['temp']['dateoccured1'])) {
		tempvar($_SESSION['temp']['dateoccured1'], "09");
	}else {
		tempvar($month, "09");
	}

	?>>September</option>
	<option value="10" <?php 
	if (isset($_SESSION['temp']['dateoccured1'])) {
		tempvar($_SESSION['temp']['dateoccured1'], "10");
	}else {
		tempvar($month, "10");
	}

	?>>October</option>
	<option value="11" <?php 
	if (isset($_SESSION['temp']['dateoccured1'])) {
		tempvar($_SESSION['temp']['dateoccured1'], "11");
	}else {
		tempvar($month, "11");
	}
	?>>November</option>
	<option value="12" <?php 
	if (isset($_SESSION['temp']['dateoccured1'])) {
		tempvar($_SESSION['temp']['dateoccured1'], "12");
	}else {
		tempvar($month, "12");
	}
	?>>December</option>
	</select>
	<?php
	// now that above is taken care of, it's time to do the date of the month
	$day = date("d");
	?>
	<select class="safetydate" name="dateoccured2" id="dateoccured2">
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "01");
	}else {
		tempvar($day, "01");
	}
	?>>01</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "02");
	}else {
		tempvar($day, "02");
	}


	?>>02</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "03");
	}else {
		tempvar($day, "03");
	}

	?>>03</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "04");
	}else {
		tempvar($day, "04");
	}

	?>>04</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "05");
	}else {
		tempvar($day, "05");
	}


	?>>05</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "06");
	}else {
		tempvar($day, "06");
	}


	?>>06</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "07");
	}else {
		tempvar($day, "07");
	}
	?>>07</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "08");
	}else {
		tempvar($day, "08");
	}

	?>>08</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "09");
	}else {
		tempvar($day, "09");
	}


	?>>09</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "10");
	}else {
		tempvar($day, "10");
	}

	?>>10</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "11");
	}else {
		tempvar($day, "11");
	}

	?>>11</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "12");
	}else {
		tempvar($day, "12");
	}

	?>>12</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "13");
	}else {
		tempvar($day, "13");
	}
	?>>13</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "14");
	}else {
		tempvar($day, "14");
	}
	?>>14</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "15");
	}else {
		tempvar($day, "15");
	}


	?>>15</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "16");
	}else {
		tempvar($day, "16");
	}
	?>>16</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "17");
	}else {
		tempvar($day, "17");
	}
	?>>17</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "18");
	}else {
		tempvar($day, "18");
	}

	?>>18</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "19");
	}else {
		tempvar($day, "19");
	}		
	?>>19</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "20");
	}else {
		tempvar($day, "20");
	}		
	?>>20</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "21");
	}else {
		tempvar($day, "21");
	}		
	?>>21</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "22");
	}else {
		tempvar($day, "22");
	}		
	?>>22</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "23");
	}else {
		tempvar($day, "23");
	}
	?>>23</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "24");
	}else {
		tempvar($day, "24");
	}		
	?>>24</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "25");
	}else {
		tempvar($day, "25");
	}		
	?>>25</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "26");
	}else {
		tempvar($day, "26");
	}		
	?>>26</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "27");
	}else {
		tempvar($day, "27");
	}		
	?>>27</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "28");
	}else {
		tempvar($day, "28");
	}		
	?>>28</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "29");
	}else {
		tempvar($day, "29");
	}		
	?>>29</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "30");
	}else {
		tempvar($day, "30");
	}		
	?>>30</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "31");
	}else {
		tempvar($day, "31");
	}		
	?>>31</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured2'])) {
		tempvar($_SESSION['temp']['dateoccured2'], "32");
	}else {
		tempvar($day, "32");
	}		
	?>>32</option>
	</select>
	<?php
	// The month and the day are done.  Now let's get this year things situated.
	$year = date("Y");
	?>
	<select class="safetydate" name="dateoccured3" id="dateoccured3">
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured3'])) {
		tempvar($_SESSION['temp']['dateoccured3'], "2000");
	}else {
		tempvar($year, "2000");
	}

	?>>2000</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured3'])) {
		tempvar($_SESSION['temp']['dateoccured3'], "2001");
	}else {
		tempvar($year, "2001");
	}		
	?>>2001</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured3'])) {
		tempvar($_SESSION['temp']['dateoccured3'], "2002");
	}else {
		tempvar($year, "2002");
	}		
	?>>2002</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured3'])) {
		tempvar($_SESSION['temp']['dateoccured3'], "2003");
	}else {
		tempvar($year, "2003");
	}		
	?>>2003</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured3'])) {
		tempvar($_SESSION['temp']['dateoccured3'], "2004");
	}else {
		tempvar($year, "2004");
	}		
	?>>2004</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured3'])) {
		tempvar($_SESSION['temp']['dateoccured3'], "2005");
	}else {
		tempvar($year, "2005");
	}		
	?>>2005</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured3'])) {
		tempvar($_SESSION['temp']['dateoccured3'], "2006");
	}else {
		tempvar($year, "2006");
	}		
	?>>2006</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured3'])) {
		tempvar($_SESSION['temp']['dateoccured3'], "2007");
	}else {
		tempvar($year, "2007");
	}		
	?>>2007</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured3'])) {
		tempvar($_SESSION['temp']['dateoccured3'], "2008");
	}else {
		tempvar($year, "2008");
	}		
	?>>2008</option>
	<option <?php 
	if (isset($_SESSION['temp']['dateoccured3'])) {
		tempvar($_SESSION['temp']['dateoccured3'], "2009");
	}else {
		tempvar($year, "2009");
	}		
	?>>2009</option>
	<option <?php 
	if (isset($_SESSION['temp']['temp']['dateoccured3'])) {
		tempvar($_SESSION['temp']['dateoccured3'], "2010");
	}else {
		tempvar($year, "2010");
	}		
	?>>2010</option>
	</select></td>
	</tr>
	<tr>
	<td></td>
	<td></td>
	<td></td>
	</tr>
	<tr>
	<td class="left"><label for="approxtime">Approximate Time:</label><span class="small">
	(0000)</span></td>
	<td class="left"><input name="approxtime_na" id="approxtime_na" type="checkbox" <?php 
				if ($_SESSION['temp']['approxtime_na'] == "Not Applicable") {
					echo "checked=\"checked\"";
				}
				?> value="Not Applicable" /><label for="approxtime_na">N/A</label></td>
	<td class="right"><input name="approxtime" id="approxtime" maxlength="4" type="text" 
	value="<?php echo $_SESSION['temp']['approxtime']; ?>" /></td>
	</tr>
	<tr>
	<td class="left"><label for="location">Location:</label></td>
	<td class="left"><input name="location_na" id="location_na" type="checkbox" <?php 
		if ($_SESSION['temp']['location_na'] == "Not Applicable") {
			echo "checked=\"checked\"";
		}
		?> value="Not Applicable" /><label for="location_na">N/A</label></td>
	<td class="right"><input name="location" id="location" maxlength="200" type="text" 
	value="<?php echo $_SESSION['temp']['location']; ?>" /></td>
	</tr>
	<tr>
	<td colspan="3"></td>
	</tr>
	<tr>
	<td colspan="3"><br /></td>
	</tr>
	<tr>
	<td class="left"><label for="description">Description of occurrence or suggestion:</label></td>
	<td></td>
	<td></td>
	</tr>
	<tr>
	<td colspan="3">
<script language="JavaScript" type="text/javascript">
<!--
//build new richTextEditor
var rte1 = new richTextEditor('description');
<?php
$content = rteSafe($_SESSION['temp']['description']);
?>
rte1.html = '<?php echo $content; ?>';
rte1.toggleSrc = false;
rte1.build();
//-->
</script>

	</td>
	</tr>
	<tr>
	<td colspan="3"></td>
	</tr>
	<tr>
	<td colspan="3"><input name="submit" id="submit" type="submit" maxlength="200" 
	value="Submit" /></td>
	</tr>
	</table>
</form>
</div>
</div>
</body>
</html>
<?php
}else {
header("Location: /index.php");
}
?>

 

Processor Text

<?php require_once(".#######")?>
<?php
if ($_SESSION['controller'] == true) {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php require_once($docroot . "#######"); ?>
</head>
<body id="safety">
<div id="logo"><p>@@#####</p></div>
<div id="safetydiv">
<div id="box" style="text-align:left;">
<br />

	<?php
$errorhandler = "";
// errorhandling here if needed
if (isset($_POST['submit'])) {
$errorhandler = "";
$todaysdate = date("m/d/Y");
$todaysdate = strtotime($todaysdate);
$_SESSION['temp']['todaysdate'] = $todaysdate;
$_SESSION['temp']['status'] = $_POST['status'];
$_SESSION['temp']['name'] = $_POST['name'];
$_SESSION['temp']['title'] = $_POST['title'];
$_SESSION['temp']['phone'] = $_POST['phone'];
$_SESSION['temp']['email'] = $_POST['email'];
$_SESSION['temp']['dateoccured_na'] = $_POST['dateoccured_na'];
$_SESSION['temp']['dateoccured1'] = $_POST['dateoccured1'];
$_SESSION['temp']['dateoccured2'] = $_POST['dateoccured2'];
$_SESSION['temp']['dateoccured3'] =	$_POST['dateoccured3'];
$_SESSION['temp']['approxtime_na'] = $_POST['approxtime_na'];
$_SESSION['temp']['approxtime'] = $_POST['approxtime'];
$_SESSION['temp']['location_na'] = $_POST['location_na'];
$_SESSION['temp']['location'] = $_POST['location'];
$_SESSION['temp']['description'] = $_POST['description'];
switch($_SESSION['temp']['status']) {
	case "fullidentity":
		if (($_SESSION['temp']['name'] == "") || ($_SESSION['temp']['title'] == "")
		|| ($_SESSION['temp']['phone'] == "") || ($_SESSION['temp']['email'] == "")) {
$errorhandler .= "
<br />
You selected Full Identity. The following fields are required:
<br /><br />
Name<br />
Phone<br />
Email Address
<br /><br />";
		}

		break;
	case "confidential":
			if (($_SESSION['temp']['name'] == "") || ($_SESSION['temp']['title'] == "")
				|| ($_SESSION['temp']['phone'] == "") || ($_SESSION['temp']['email'] == "")) {
$errorhandler .= "
<br />
You selected Confidential. The following fields are required:
<br /><br />
Name<br />
Phone<br />
Email Address
<br /><br />";	
		}
		break;

}
if ($_SESSION['temp']['approxtime_na'] != "Not Applicable")
	if ($_SESSION['temp']['approxtime'] == "") {
		$errorhandler .= "If Not Applicable is not selected then Approximate ";
		$errorhandler .= "Time is required.<br />";
	}
}
if ($_SESSION['temp']['location_na'] != "Not Applicable") {
	if ($_SESSION['temp']['location'] == "") {
		$errorhandler .= "If Not Applicable is not selected then Location is required.<br />";
	}
}
if ($_SESSION['temp']['description'] == "") {
	$errorhandler .= "The description is required and it was left blank.<br />";
}
	if ($errorhandler != "") {
		echo "<span style=\"color:red\">";
		echo "The following errors have occurred:";
		echo "<br />";
		echo "<br />";
		echo $errorhandler;
		echo "</span>";
		echo "<br />";
		echo "<br />";
		echo "<form action=\"index.php\" method=\"post\">";
		echo "<input name=\"return\" id=\"return\" type=\"submit\" value=\"Return To Form\" />";
		echo "</form>";
	}
if ($errorhandler == "") {
// get date, status, and personal information
	$_SESSION['temp']['todaysdate'] = $todaysdate;
	$_SESSION['temp']['status'] = deepclean($_SESSION['temp']['status']);
	$_SESSION['temp']['name'] = deepclean($_SESSION['temp']['name']);
	$_SESSION['temp']['title'] = deepclean($_SESSION['temp']['title']);
	$_SESSION['temp']['phone'] = deepclean($_SESSION['temp']['phone']);
	$_SESSION['temp']['email'] = deepclean($_SESSION['temp']['email']);
	// if na get not applicable, if not format date properly
	if ($_SESSION['temp']['dateoccured_na'] == "Not Applicable") {
		$_SESSION['temp']['dateoccured'] = "Not Applicable";
	}else {
		$_SESSION['temp']['dateoccured'] = $_SESSION['temp']['dateoccured1'] . "/" . 
		$_SESSION['temp']['dateoccured2'] . "/" . $_SESSION['temp']['dateoccured3'];
	}
	// if na get not applicable, if not get approximate time
	if ($_SESSION['temp']['approxtime_na'] == "Not Applicable") {
		$_SESSION['temp']['approxtime'] = "Not Applicable";
	}else {
		$_SESSION['temp']['approxtime'] = deepclean($_SESSION['temp']['approxtime']);
	}
	// if na get not applicable, if not get Location
	if ($_SESSION['temp']['location_na'] == "Not Applicable") {
		$_SESSION['temp']['location'] = "Not Applicable";
	}else {
		$_SESSION['temp']['location'] = deepclean($_SESSION['temp']['location']);
	}
	// get the allowed tags, and thouroughly clean the description of
	// anything that might be dangerous.
	$allowedtags = "<br>, <ul>, <li>, <ol>, <b>, <strong>, <u>";
$_SESSION['temp']['description'] = strip_tags($_SESSION['temp']['description'], $allowedtags);
$_SESSION['temp']['description'] = mysql_real_escape_string($_SESSION['temp']['description']);
$_SESSION['temp']['description'] = trim($_SESSION['temp']['description']);
	// at this point where going to go ahead and say that all variables are
	// properly prepared and cleaned.
	// This is where we do our database work and send an email to the person.
	$insert = "INSERT INTO safetyreport (todaysdate, dateoccured, time, location, description, status, name, jobtitle, phone, email) VALUES ('" . $_SESSION['temp']['todaysdate'] . "', '" .$_SESSION['temp']['dateoccured'] . "', '" . $_SESSION['temp']['approxtime'] . "', '" . $_SESSION['temp']['location'] . "', '" . $_SESSION['temp']['description'] . "', '" . $_SESSION['temp']['status'] . "', '" . $_SESSION['temp']['name'] . "', '" . $_SESSION['temp']['title'] . "', '" . $_SESSION['temp']['phone'] . "', '" . $_SESSION['temp']['email'] . "');";
	// perform query in an if, so I can send some emails if it's successfull.
	if (mysql_query($insert)) {
		// if the query was successful it's time to send some emails.
		// start review form
		?>
		<h1>Review Information</h1>
<?php
echo "<br />";
echo "<strong>Status:</strong> " . $_SESSION['temp']['status'];
echo "<br />";
echo "<strong>Name:</strong> " . stripslashes($_SESSION['temp']['name']);
echo "<br />";
echo "<strong>Job Title:</strong> " . stripslashes($_SESSION['temp']['title']);
echo "<br />";
echo "<strong>Phone:</strong> " . stripslashes($_SESSION['temp']['phone']);
echo "<br />";
echo "<strong>Email:</strong> " . stripslashes($_SESSION['temp']['email']);
echo "<br />";
$dateoccured = $_SESSION['temp']['dateoccured1'] . "/" . $_SESSION['temp']['dateoccured2'] . "/" .  $_SESSION['temp']['dateoccured3'];
echo "<strong>Date Occured:</strong> " . $dateoccured;
echo "<br />";
echo "<strong>Approximate Time:</strong> " . stripslashes($_SESSION['temp']['approxtime']);
echo "<br />";
echo "<strong>Location:</strong> " . stripslashes($_SESSION['temp']['location']);
echo "<br />";
echo "<strong>Description:</strong> ";
echo "<br />"; 
echo stripslashes($_SESSION['temp']['description']);
echo "<br />";
echo "<br />";
?>
<form name="sendoff" id="sendoff" action="index3.php" method="post">
<input type="Button" name="printit" value="Print a Copy for your Records" onclick="javascript:window.print();">
</form>

<?php
// end review form.
// now that everything is done, and the review form has been shown, if they supplied an email
// address we need to send them a copy of that email address, as well as sending an email 
// address to the administrators, as they requested to have new reports emailed to them
// upon entry
#Admin Email
$message = "-New Safety Report Entry-
Current Date: " . $_SESSION['temp']['todaysdate'] . 
"Approximate Time: " . $_SESSION['temp']['approxtime'] . 
"Location: " . $_SESSION['temp']['location'] . 
"Description: " . $_SESSION['temp']['description'] . 
"Status: " . $_SESSION['temp']['status'];
// based on there status, the user information can look different to admins
if ($_SESSION['temp']['status'] == "fullidentity" || 
$_SESSION['temp']['status'] == "confidential") {
$message .= "Name: " . $_SESSION['temp']['name'];
$message .= "Job Title: " . $_SESSION['temp']['title'];
$message .= "Phone: " . $_SESSION['temp']['phone'];
$message .= "Email: " . $_SESSION['temp']['email'];	

}elseif ($_SESSION['temp']['status'] == "anonymous") {
$message .= "Name: Masked";
$message .= "Job Title: Masked";
$message .= "Phone: Masked";
$message .= "Email: Masked";	
}
$to = "businessman332211@hotmail.com";
$subject = "New Safety Report Entry";
$headers = "From: donot-reply@9ksafety.com";
// send mail to admins
mail($to, $subject, $message, $headers);

// Now that sending the mail to admins is completely finished it's time to perform the final act
// which is sending an email to the user's as well
# User Email
// first we have to check if there is a provided email, if so send one
	if ($_SESSION['temp']['email'] != "") {
		$userto = $_SESSION['temp']['email'];
		$usermessage = "-New Safety Report Entry-";
		$usermessage .= "Current Date: " . $_SESSION['temp']['todaysdate'];
		$usermessage .= "Approximate Time: " . $_SESSION['temp']['approxtime'];
		$usermessage .= "Location: " . $_SESSION['temp']['location'];
		$usermessage .= "Description: " . $_SESSION['temp']['description'];
		$usermessage .= "Status: " . $_SESSION['temp']['status'];
		$usermessage .= "Name: " . $_SESSION['temp']['name'];
		$usermessage .= "Job Title: " . $_SESSION['temp']['title'];
		$usermessage .= "Phone: " . $_SESSION['temp']['phone'];
		$usermessage .= "Email: " . $_SESSION['temp']['email'];
		$usersubject = "Notification From 9kSafety, safety report entry";
		$userheaders = "From: donotreply@9ksafety.com";
		// send user mail
		mail($userto, $usersubject, $usermessage, $userheaders);
	}// ends if mail
	unset($_SESSION['temp']); // sessions emptied
}// ends mysql query
}// end the entire process, and close the script out

// script finished.


?>
</div> <!-- End centering box -->
</div>
</body>
</html>
<?php
}else {
header("Location: /index.php");
}
?>

 

Well that is all the code on those 2 pages.

 

I have tried the following

1. Echoing out the description on the next page, just echoing it out.

It ends up working fine here. but on the second time it doesn't.

2. Trying to let the script run.

When it does it adds the rnrn at the top and bottom (trim removes it from the top)

On top of that (I could of sworn it wasn't doing that at first), it has been inserting a bunch of tag's in the test emails, I am really wondering what is going on.

 

With the full script if someone can help me figure out what is causing this problme, it would be greatly appreciated, because as of right now, I am totally confused.

Link to comment
Share on other sites

Ok, something really bad is going on here.

 

When I do this

// $_SESSION['temp']['description'] = strip_tags($_SESSION['temp']['description'], $allowedtags);

//  $_SESSION['temp']['description'] = mysql_real_escape_string($_SESSION['temp']['description']);

// $_SESSION['temp']['description'] = trim($_SESSION['temp']['description']);

$_SESSION['temp']['description'] = $_SESSION['temp']['description'];

 

It goes to a blank page instead of doing anything(not a syntax error, I mean the layout is there but nothing outputs)

when I don't then it just has the trims.

 

What is going on, this is the most confusing problem I have ever faced.

Link to comment
Share on other sites

Source for the "form" page

## text here ##

</p>

<hr />

<form action="index2.php" method="post" name="submitform" id="submitform" onsubmit="return submitForm();">

<ul>

<li><input name="status"

onclick="toggleon('hide1', 'name'); toggleon('hide2', 'title'); toggleon('hide3', 'phone'); toggleon('hide4', 'email');" id="fullidentity" value="fullidentity" type="radio" checked="checked" /><label for="status"><span class="bold">Full Identity</span> -  <span class="smalltext">I wish to receive feedback and correspond with Safety about this report.</span></label></li>

 

<li><input name="status"

onclick="toggleon('hide1', 'name'); toggleon('hide2', 'title'); toggleon('hide3', 'phone'); toggleon('hide4', 'email');" id="confidential" value="confidential" type="radio" /><label for="status"><span class="bold">Confidential</span> - <span class="smalltext">I would like this report to be confidential but also get feedback.</span></label></li>

<li><input name="status"

onclick="toggleoff('hide1', 'name'); toggleoff('hide2', 'title'); toggleoff('hide3', 'phone'); toggleoff('hide4','email');"id="anonymous" value="anonymous" type="radio" /><label for="status"><span class="bold">Anonymous</span> -  <span class="smalltext">I wish to remain anonymous and only receive acknowledgement of submission.<br />                                              (email address must be provided for acknowledgement)</span></label></li>

</ul>

<br /><br />

 

<table align="center">

<tr>

 

<td class="left"><label for="name">Name:</label></td>

<td></td>

<td class="right"><span class="red" id="hide1">*</span>

<input name="name" id="name" class="require" type="text" maxlength="200" value="" /></td>

</tr>

<tr>

<td class="left"><label for="title">Job Title/Description:</label></td>

<td></td>

 

<td class="right"><span class="red" id="hide2">*</span>

<input name="title" id="title" class="require"  type="text" maxlength="200" value="" /></td>

</tr>

<tr>

<td class="left"><label for="phone">Phone:</label></td>

<td></td>

<td class="right"><span class="red" id="hide3">*</span>

<input name="phone" id="phone" class="require"  type="text" maxlength="200" value="" /></td>

 

</tr>

<tr>

<td class="left"><label for="email">Email Address:</label></td>

<td></td>

<td class="right"><span class="red" id="hide4">*</span>

<input name="email" id="email" class="require" type="text" maxlength="200" value="" /></td>

</tr>

<tr>

 

<td class="left"><label for="dateoccured">Date Occurred:</label></td>

<td class="left"><input name="dateoccured_na"  id="dateoccured_na" type="checkbox" value="Not Applicable" /><label for="dateoccured_na">N/A</label></td>

<td class="right"> <select class="safetydate" name="dateoccured1" id="dateoccured1">

<option value="01" >January</option>

 

<option value="02" selected="selected">February</option>

<option value="03" >March</option>

 

<option value="04" >April</option>

<option value="05" >May</option>

<option value="06" >June</option>

<option value="07" >July</option>

<option value="08" >August</option>

<option value="09" >September</option>

 

<option value="10" >October</option>

<option value="11" >November</option>

<option value="12" >December</option>

</select>

<select class="safetydate" name="dateoccured2" id="dateoccured2">

<option >01</option>

<option >02</option>

 

<option >03</option>

<option >04</option>

<option >05</option>

<option >06</option>

<option >07</option>

<option >08</option>

 

<option >09</option>

<option >10</option>

<option >11</option>

<option >12</option>

<option >13</option>

<option >14</option>

 

<option >15</option>

<option >16</option>

<option >17</option>

<option >18</option>

<option >19</option>

<option >20</option>

 

<option >21</option>

<option >22</option>

<option >23</option>

<option >24</option>

<option >25</option>

<option >26</option>

 

<option selected="selected">27</option>

<option >28</option>

<option >29</option>

<option >30</option>

<option >31</option>

<option >32</option>

 

</select>

<select class="safetydate" name="dateoccured3" id="dateoccured3">

<option >2000</option>

<option >2001</option>

<option >2002</option>

<option >2003</option>

<option >2004</option>

 

<option >2005</option>

<option >2006</option>

<option selected="selected">2007</option>

<option >2008</option>

<option >2009</option>

<option >2010</option>

 

</select></td>

</tr>

<tr>

<td></td>

<td></td>

<td></td>

</tr>

<tr>

<td class="left"><label for="approxtime">Approximate Time:</label><span class="small">

 

(0000)</span></td>

<td class="left"><input name="approxtime_na" id="approxtime_na" type="checkbox"  value="Not Applicable" /><label for="approxtime_na">N/A</label></td>

<td class="right"><input name="approxtime" id="approxtime" maxlength="4" type="text"

value="" /></td>

</tr>

<tr>

<td class="left"><label for="location">Location:</label></td>

<td class="left"><input name="location_na" id="location_na" type="checkbox"  value="Not Applicable" /><label for="location_na">N/A</label></td>

 

<td class="right"><input name="location" id="location" maxlength="200" type="text"

value="" /></td>

</tr>

<tr>

<td colspan="3"></td>

</tr>

<tr>

<td colspan="3"><br /></td>

</tr>

<tr>

 

<td class="left"><label for="description">Description of occurrence or suggestion:</label></td>

<td></td>

<td></td>

</tr>

<tr>

<td colspan="3">

<script language="JavaScript" type="text/javascript">

<!--

//build new richTextEditor

var rte1 = new richTextEditor('description');

rte1.html = '';

rte1.toggleSrc = false;

rte1.build();

//-->

</script>

 

</td>

 

</tr>

<tr>

<td colspan="3"></td>

</tr>

<tr>

<td colspan="3"><input name="submit" id="submit" type="submit" maxlength="200"

value="Submit" /></td>

</tr>

</table>

</form>

 

</div>

</div>

</body>

</html>

 

Source for the output

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<meta name="keywords" content="Keywords Here" />

<meta name="description" content="Description Here" />

<script type="text/javascript" src="/master/javascript/global.js"></script> <!-- Global Javascript -->

<script type="text/javascript" src="/master/ajax/global.js"></script> <!-- Global Ajax -->

<link rel="stylesheet" type="text/css" href="/master/css/global.css" /> <!-- Global CSS -->

<title>9ksafety</title></head>

<body id="safety">

 

<div id="logo"><p>Employee Safety Report</p></div>

<div id="safetydiv">

<div id="box" style="text-align:left;">

<br />

 

<h1>Review Information</h1>

<br /><strong>Status:</strong> anonymous<br /><strong>Name:</strong> <br /><strong>Job Title:</strong> <br /><strong>Phone:</strong> <br /><strong>Email:</strong> <br /><strong>Date Occured:</strong> 02/27/2007<br /><strong>Approximate Time:</strong> Not Applicable<br /><strong>Location:</strong> Not Applicable<br /><strong>Description:</strong> <br />test<br />'test'<br />"test"<br /><br /><br />test<br /><br /><br />rnrnrn<br /><br /><form name="sendoff" id="sendoff" action="index3.php" method="post">

 

<input type="Button" name="printit" value="Print a Copy for your Records" onclick="javascript:window.print();">

</form>

 

</div> <!-- End centering box -->

</div>

</body>

</html>

 

I just noticed, it doesn't always do it.  Only sometimes.

 

That above is the output, I have been scouring google for an answer, the only reason I am not using tinyMCE or FCKEditor is because this time I need somthing that you can paste word document text straight into it.  The other 2 come up with a popup and you have to paste it in there, if you paste it directly you get other popups.  He wants that setup where you can directly paste word documents in there.

 

Also it's strange but there is not text area.

I don't even see one in the output.  But I didn't see anythin gin the instructions on using one.

 

I was using the demo pages, and what information I could scrape up off there dead forum.

Link to comment
Share on other sites

My guess is this code snippet:

 

<!--
//build new richTextEditor
var rte1 = new richTextEditor('description');
rte1.html = '';
rte1.toggleSrc = false;
rte1.build();
//-->

 

is building a textarea.  You're obviously typing these comments into something and it doesn't make much logical sense for it to not be a textarea control.

 

If you're using FF with the WebDeveloper plug-in, use the View Source -> View Generated Source after the page loads and paste that.

Link to comment
Share on other sites

<html xmlns="http://www.w3.org/1999/xhtml"><head>


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="keywords" content="Keywords Here">
<meta name="description" content="Description Here">
<script type="text/javascript" src="/master/javascript/global.js"></script><!-- Global Javascript --> 
<script type="text/javascript" src="/master/ajax/global.js"></script><!-- Global Ajax --> 
<link rel="stylesheet" type="text/css" href="/master/css/global.css"><!-- Global CSS --><title>9ksafety</title> 
<script language="JavaScript" type="text/javascript" src="../rte/html2xhtml.js"></script>
<script language="JavaScript" type="text/javascript" src="../rte/richtext_compressed.js"></script>

<script language="JavaScript" type="text/javascript">
function toggleoff(offtarget1, offtarget2) {
document.getElementById(offtarget1).style.display='none';
document.getElementById(offtarget2).style.background='#FFFFFF';
}

function toggleon(ontarget1, ontarget2) {
document.getElementById(ontarget1).style.display='inline';	
document.getElementById(ontarget2).style.background='#CCCC99';
}
//-->
</script>
<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 = " + htmlDecode(document.RTEDemo.rte1.value));
return false;
}

//Usage: initRTE(imagesPath, includesPath, cssFile, genXHTML, encHTML)
initRTE("../rte/images/", "./", "", true);
//-->
</script><style type="text/css">@import "./rte.css";</style></head><noscript><p><b>Javascript must be enabled to use this form.</b></p></noscript><body id="safety"><iframe id="cp" src="./palette.htm" marginwidth="0" marginheight="0" style="visibility: hidden; position: absolute;" frameborder="0" height="100" scrolling="no" width="150"></iframe>



<div id="logo"><p>Reaa</p></div>
<div id="safetydiv">
<div id="box">
<p>
website text goes here generally.
</p>
<hr>
<form action="index2.php" method="post" name="submitform" id="submitform" onsubmit="return submitForm();">
<ul>
<li><input name="status" onclick="toggleon('hide1', 'name'); toggleon('hide2', 'title'); toggleon('hide3', 'phone'); toggleon('hide4', 'email');" id="fullidentity" value="fullidentity" checked="checked" type="radio"><label for="status"><span class="bold">Full Identity</span> -  <span class="smalltext">I wish to receive feedback and correspond with Safety about this report.</span></label></li>

<li><input name="status" onclick="toggleon('hide1', 'name'); toggleon('hide2', 'title'); toggleon('hide3', 'phone'); toggleon('hide4', 'email');" id="confidential" value="confidential" type="radio"><label for="status"><span class="bold">Confidential</span> - <span class="smalltext">I would like this report to be confidential but also get feedback.</span></label></li>
<li><input name="status" onclick="toggleoff('hide1', 'name'); toggleoff('hide2', 'title'); toggleoff('hide3', 'phone'); toggleoff('hide4','email');" id="anonymous" value="anonymous" type="radio"><label for="status"><span class="bold">Anonymous</span> -  <span class="smalltext">I wish to remain anonymous and only receive acknowledgement of submission.<br>                                              (email address must be provided for acknowledgement)</span></label></li>
</ul>
<br><br>

	<table align="center">
	<tbody><tr>

	<td class="left"><label for="name">Name:</label></td>
	<td></td>
	<td class="right"><span class="red" id="hide1">*</span>
<input name="name" id="name" class="require" maxlength="200" value="" type="text"></td>
	</tr>
	<tr>
	<td class="left"><label for="title">Job Title/Description:</label></td>
	<td></td>

	<td class="right"><span class="red" id="hide2">*</span>
<input name="title" id="title" class="require" maxlength="200" value="" type="text"></td>
	</tr>
	<tr>
	<td class="left"><label for="phone">Phone:</label></td>
	<td></td>
	<td class="right"><span class="red" id="hide3">*</span>
<input name="phone" id="phone" class="require" maxlength="200" value="" type="text"></td>

	</tr>
	<tr>
	<td class="left"><label for="email">Email Address:</label></td>
	<td></td>
	<td class="right"><span class="red" id="hide4">*</span>
<input name="email" id="email" class="require" maxlength="200" value="" type="text"></td>
	</tr>
	<tr>

	<td class="left"><label for="dateoccured">Date Occurred:</label></td>
	<td class="left"><input name="dateoccured_na" id="dateoccured_na" value="Not Applicable" type="checkbox"><label for="dateoccured_na">N/A</label></td>
	<td class="right">		<select class="safetydate" name="dateoccured1" id="dateoccured1">
	<option value="01">January</option>

	<option value="02" selected="selected">February</option>
	<option value="03">March</option>

	<option value="04">April</option>
	<option value="05">May</option>
	<option value="06">June</option>
	<option value="07">July</option>
	<option value="08">August</option>
	<option value="09">September</option>

	<option value="10">October</option>
	<option value="11">November</option>
	<option value="12">December</option>
	</select>
			<select class="safetydate" name="dateoccured2" id="dateoccured2">
	<option>01</option>
	<option>02</option>

	<option>03</option>
	<option>04</option>
	<option>05</option>
	<option>06</option>
	<option>07</option>
	<option>08</option>

	<option>09</option>
	<option>10</option>
	<option>11</option>
	<option>12</option>
	<option>13</option>
	<option>14</option>

	<option>15</option>
	<option>16</option>
	<option>17</option>
	<option>18</option>
	<option>19</option>
	<option>20</option>

	<option>21</option>
	<option>22</option>
	<option>23</option>
	<option>24</option>
	<option>25</option>
	<option>26</option>

	<option selected="selected">27</option>
	<option>28</option>
	<option>29</option>
	<option>30</option>
	<option>31</option>
	<option>32</option>

	</select>
			<select class="safetydate" name="dateoccured3" id="dateoccured3">
	<option>2000</option>
	<option>2001</option>
	<option>2002</option>
	<option>2003</option>
	<option>2004</option>

	<option>2005</option>
	<option>2006</option>
	<option selected="selected">2007</option>
	<option>2008</option>
	<option>2009</option>
	<option>2010</option>

	</select></td>
	</tr>
	<tr>
	<td></td>
	<td></td>
	<td></td>
	</tr>
	<tr>
	<td class="left"><label for="approxtime">Approximate Time:</label><span class="small">

	(0000)</span></td>
	<td class="left"><input name="approxtime_na" id="approxtime_na" value="Not Applicable" type="checkbox"><label for="approxtime_na">N/A</label></td>
	<td class="right"><input name="approxtime" id="approxtime" maxlength="4" value="" type="text"></td>
	</tr>
	<tr>
	<td class="left"><label for="location">Location:</label></td>
	<td class="left"><input name="location_na" id="location_na" value="Not Applicable" type="checkbox"><label for="location_na">N/A</label></td>

	<td class="right"><input name="location" id="location" maxlength="200" value="" type="text"></td>
	</tr>
	<tr>
	<td colspan="3"></td>
	</tr>
	<tr>
	<td colspan="3"><br></td>
	</tr>
	<tr>

	<td class="left"><label for="description">Description of occurrence or suggestion:</label></td>
	<td></td>
	<td></td>
	</tr>
	<tr>
	<td colspan="3">
<script language="JavaScript" type="text/javascript">
<!--
//build new richTextEditor
var rte1 = new richTextEditor('description');
rte1.html = '';
rte1.toggleSrc = false;
rte1.build();
//-->
</script><table style="border: 1px solid rgb(0, 0, 0);" cellpadding="0" cellspacing="0" width="500">
<tbody><tr>

	<td>
	<table class="rteBack" id="toolbar1_description" cellpadding="2" cellspacing="0" width="100%">
		<tbody><tr>
			<td>
				<select id="formatblock_description" onchange="selectFont('description', this.id);">
					<option value="">[style]</option>
					<option value="<p>">Paragraph <p></option>

					<option value="<h1>">Heading 1 <h1></option>
					<option value="<h2>">Heading 2 <h2></option>
					<option value="<h3>">Heading 3 <h3></option>
					<option value="<h4>">Heading 4 <h4></option>
					<option value="<h5>">Heading 5 <h5></option>

					<option value="<h6>">Heading 6 <h6></option>
					<option value="<address>">Address <ADDR></option>
					<option value="<pre>">Formatted <pre></option>
				</select>
			</td>
			<td>

				<select id="fontname_description" onchange="selectFont('description', this.id)">
					<option value="Font" selected="selected">[Font]</option>
					<option value="Arial, Helvetica, sans-serif">Arial</option>
					<option value="Courier New, Courier, mono">Courier New</option>
					<option value="Times New Roman, Times, serif">Times New Roman</option>
					<option value="Verdana, Arial, Helvetica, sans-serif">Verdana</option>

				</select>
			</td>
			<td>
				<select id="fontsize_description" onchange="selectFont('description', this.id);">
					<option value="Size">[size]</option>
					<option value="1">1</option>
					<option value="2">2</option>

					<option value="3">3</option>
					<option value="4">4</option>
					<option value="5">5</option>
					<option value="6">6</option>
					<option value="7">7</option>
				</select>

			</td>
			<td width="100%"></td>
		</tr>
	</tbody></table>
	<table class="rteBack" id="toolbar2_description" cellpadding="0" cellspacing="0" width="100%">
		<tbody><tr>
			<td><img class="rteImage" src="../rte/images/bold.gif" alt="Bold" title="Bold" onmousedown="rteCommand('description', 'bold')" height="24" width="25"></td>
			<td><img class="rteImage" src="../rte/images/italic.gif" alt="Italic" title="Italic" onmousedown="rteCommand('description', 'italic')" height="24" width="25"></td>
			<td><img class="rteImage" src="../rte/images/underline.gif" alt="Underline" title="Underline" onmousedown="rteCommand('description', 'underline')" height="24" width="25"></td>

			<td><img class="rteImage" src="../rte/images/left_just.gif" alt="Align Left" title="Align Left" onmousedown="rteCommand('description', 'justifyleft')" height="24" width="25"></td>
			<td><img class="rteImage" src="../rte/images/centre.gif" alt="Center" title="Center" onmousedown="rteCommand('description', 'justifycenter')" height="24" width="25"></td>
			<td><img class="rteImage" src="../rte/images/right_just.gif" alt="Align Right" title="Align Right" onmousedown="rteCommand('description', 'justifyright')" height="24" width="25"></td>
			<td><img class="rteImage" src="../rte/images/hr.gif" alt="Horizontal Rule" title="Horizontal Rule" onmousedown="rteCommand('description', 'inserthorizontalrule')" height="24" width="25"></td>
			<td><img class="rteImage" src="../rte/images/numbered_list.gif" alt="Ordered List" title="Ordered List" onmousedown="rteCommand('description', 'insertorderedlist')" height="24" width="25"></td>
			<td><img class="rteImage" src="../rte/images/list.gif" alt="Unordered List" title="Unordered List" onmousedown="rteCommand('description', 'insertunorderedlist')" height="24" width="25"></td>
			<td><img class="rteImage" src="../rte/images/outdent.gif" alt="Outdent" title="Outdent" onmousedown="rteCommand('description', 'outdent')" height="24" width="25"></td>
			<td><img class="rteImage" src="../rte/images/indent.gif" alt="Indent" title="Indent" onmousedown="rteCommand('description', 'indent')" height="24" width="25"></td>
			<td><div id="forecolor_description"><img class="rteImage" src="../rte/images/textcolor.gif" alt="Text Color" title="Text Color" onmousedown="dlgColorPalette('description', 'forecolor', ''); return false;" height="24" width="25"></div></td>

			<td><div id="hilitecolor_description"><img class="rteImage" src="../rte/images/bgcolor.gif" alt="Background Color" title="Background Color" onmousedown="dlgColorPalette('description', 'hilitecolor', ''); return false;" height="24" width="25"></div></td>
			<td><img class="rteImage" src="../rte/images/hyperlink.gif" alt="Insert Link" title="Insert Link" onmousedown="dlgInsertLink('description')" height="24" width="25"></td>
			<td><img class="rteImage" src="../rte/images/image.gif" alt="Add Image" title="Add Image" onmousedown="addImage('description')" height="24" width="25"></td>
			<td><img class="rteImage" src="../rte/images/special_chars.gif" alt="Insert Special Character" title="Insert Special Character" onmousedown="dlgInsertSpecialChar('description')" height="24" width="25"></td>
			<td><div id="table_description"><img class="rteImage" src="../rte/images/insert_table.gif" alt="Insert Table" title="Insert Table" onmousedown="dlgInsertTable('description')" height="24" width="25"></div></td>
			<td width="100%"></td>
		</tr>
	</tbody></table>
		<iframe id="description" name="description" src="./blank.htm" style="margin: 0pt; padding: 0pt; width: 100%; height: 200px;" frameborder="0"></iframe>

	</td>
</tr>
</tbody></table>
<div style="margin: 0pt; padding: 0pt;">
<input id="hdndescription" name="description" value="" type="hidden">
</div>


	</td>
	</tr>
	<tr>
	<td colspan="3"></td>

	</tr>
	<tr>
	<td colspan="3"><input name="submit" id="submit" maxlength="200" value="Submit" type="submit"></td>
	</tr>
	</tbody></table>
</form>
</div>
</div>
</body></html>

 

Here is the generated source code (also just for the future thanks for pointing out that, it will help I never new about generated source code, I always just went to source code, that might help me in the future)

 

That is the generated source code of the form, using the "generated source code" as you showed me.

Link to comment
Share on other sites

<iframe id="description" name="description" src="./blank.htm" style="margin: 0pt; padding: 0pt; width: 100%; height: 200px;" frameborder="0"></iframe>

 

My guess is you want to look inside the file pointed at by the src attribute:

 

src="./blank.htm"

Link to comment
Share on other sites

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>

<title></title>

<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

</head>

 

<body>

 

</body>

</html>

That is ALL that is in the blank.htm file.

 

Link to comment
Share on other sites

The iframe has this style:

 

style="margin: 0pt; padding: 0pt; width: 100%; height: 200px;"

 

So I believe it's set up to appear as a mock text input.

 

It's also using the id and name:

 

id="description" name="description"

 

My guess is somewhere in the javascript is an onkeydown or onkeyup handler for the iframe.

Link to comment
Share on other sites

Where do you suggest I look to try to fix the rnrn problem

It either appears at the very beginning like this

 

rnrnhello

This is some test text

 

 

Or it appears at the bottom (sometimes)

 

westtest

'test'

"test"

te

st

 

rnrnrn

 

At the very, very bottom of it, never in between, just at the top/bottom.

 

Trim successfully always removes the ones at the top, but not at the bottom lines.

 

Let me know what you think, I am really confused here.

Link to comment
Share on other sites

Actually if you look at the event handlers for the menu objects, you'll see code like:

 

onmousedown="rteCommand('description', 'bold')"

 

Tells me the iframe is being used as the editing body and all your magic is happening with javascript.  I still couldn't tell you why you're getting extra \r\n in there though.  I've ran into extra spacing using textareas, but I've never used an iframe or attempted any sort of rich editor, so I don't know what's causing your current issue.

 

The last thing I can suggest is in your blank.html, change:

 

<body>

</body>

 

to

 

<body></body>

 

You might get lucky!

Link to comment
Share on other sites

I tried altering that, but nothing else is seeming to work, I am going to get rid of this stupid editor, and use something usable.  Maybe there is a way I can make one of hte other 2, allow me to paste word document text directly in there, without those stupid popups, but nothing is worth fighting with this dumb text editor over.  Thank you all for all the help.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.