Log in

View Full Version : Passing RTE variables to PHP



steagu_ro
09-20-2006, 02:24 PM
Hi. I want to use a RTE, but i want to get the data with php and put it in MySQL.

i have the form in demo.php

<form action="target.php" method="post" name="RTEDemo" onSumbit="return submitForm();">
<input type="hidden" name="myVal" value="">
<script...>
<here is the script for submitForm() from RTE, with a small modification inside, to get the value of the rte1 into myVal:
....
updateRTE('rte1');
document.RTEDemo.myVal.value = document.RTEDemo.rte1.value;
</script>
<script....>
<!--
writeRichText('rte1',.....);
-->
</script>
<input type="submit" name="submit">
</form>


then, in target.php, i'm trying to get the value of myVal

$val = $_POST['myval'];

but... i have no value. (or i have the value from the "value" part from the hidden field)
What am i doing wrong?

thetestingsite
09-20-2006, 07:52 PM
the reason you are getting no value is because the hidden field has no value. if you wanted to get the value from the RTE, use the name of the RTE which above is rte1, then request that in the php.

codeexploiter
09-22-2006, 06:29 AM
posted by: thetestingsite
the reason you are getting no value is because the hidden field has no value. if you wanted to get the value from the RTE, use the name of the RTE which above is rte1

I wonder Then what is this code is doing ib the client-side script



posted by: steagu_ro

document.RTEDemo.myVal.value = document.RTEDemo.rte1.value;

thetestingsite
09-22-2006, 02:54 PM
The thing about that is you are trying to put the blank value of myVal into the RTE, instead of the other way. You could do that the opposite and it should work fine, but I recommend doing the way that I have mentioned above, setting up a variable that calls the value of the RTE instead. I have done this with several RTEs and it works perfectly fine for me and the application that I use them in. Just my 2 cents worth I guess.

andresmillang
04-12-2008, 11:43 PM
the rte1 value does not pass html code, what am I doing wrong?

<script language="JavaScript" type="text/javascript" src="richtext_compressed.js"></script>
</head>
<body>
<form name="homevar" action="php.php" method="post" onSubmit="return submitForm();">
<script language="JavaScript" type="text/javascript">
<!--
//Usage: initRTE(imagesPath, includesPath, cssFile)
initRTE("images/", "", "");
//-->
</script>
<noscript><p><b>Javascript must be enabled to use this form.</b></p></noscript><?


$file =" <b>hello world</b>";

print "
<script language=\"JavaScript\" type=\"text/javascript\">
<!--
//Usage: writeRichText(fieldname, html, width, height, buttons, readOnly)
writeRichText('rte1', '";

print "$file"; //this part works fine

print "', 400, 200, true, false);
//-->
</script>";

?>

<input type="submit" name="submit" value="Submit">
</form>
</body>


php.php



<?php
print_r ($_REQUEST['rte1']);// This is showing hello world instead of <b>hello world</b>
?>
Edit/Delete Message

GuilleZapata
09-22-2010, 12:05 AM
I was reading this 2 years later I believe but if it helps in any way or maybe it helps some one else.... here you go:

Hi! I had the amost exact same problem just change <? print_r ($_REQUEST['rte1']);?> to <? echo htmlspecialchars($_REQUEST['rte1']); ?>