Results 1 to 6 of 6

Thread: Passing RTE variables to PHP

  1. #1
    Join Date
    Sep 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Passing RTE variables to PHP

    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?

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    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.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    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
    Code:
    document.RTEDemo.myVal.value = document.RTEDemo.rte1.value;

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    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.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #5
    Join Date
    Apr 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default please help

    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

  6. #6
    Join Date
    Sep 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 2 years later.. i think.... lol

    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']); ?>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •