Accessing a textarea field from a form

halfa

Member
I've been using the form redirect plugin to navigate to a confirmation page after a form has been completed. It's just to provide feedback to the user of the data that they have entered.

I found a J! plugin called DirectPHP which is fantastic for this sort of thing. All I have to do is enter the PHP code directly into a J! content article to retrieve each value.
ie <?php echo $_GET['members___Player_Address1'];?>

I was wondering how does the redirect plugin deal with textarea elements? My first attempt shows that the URL is truncated and therefore most of the data is missing. Which is understandable given a textarea could hold a substantial amount of data.

Is there another way that I can reference the data I need? Does the redirect store the data somewhere as well as append it to the URL?

Thanks.
 
Funnily enough, I stumbled across DirectPHP yesterday whilst trying to solve an unrelated issue. Already using it in three places to solve nasty little J! content issues like "display this if they are logged in, else display that".

AFAIK, we don't truncate any form data when we append it to the redirect URL, we just urlencode it. There may be some limits in both httpd and the browser which limit the total length of a QS, but that's about the only things I can think of. And yes, a long text area could very well exceed QS length - I think the limit is about 2Kb from what I remember.

As long as you are redirecting to a page on the same server, then you should be able to get the data out of the PHP session. All posted data should be there, because fabrikredirect.php does a _storeInSession(). So the posted data should be in:

$_SESSION['fabrik'][XX]

... where XX is your form's numeric ID. Also, in ...

$_SESSION['fabrik']['fromForm']

... should be the form ID the redirect happened on.

-- hugh
 
Thanks...I tried as you suggested but DirectPHP errored with an eval error.

I then change the redirect on the form to point to a php script which would simply output the structure of $_SESSION so that I could check exactly what I needed to get the correct values of my fields.

The script I used was simply:-

<?php
echo '<pre>';
var_dump($_SESSION);
echo '</pre>';
?>

var_dump($_SESSION) returns NULL

I had the append data switch turned off but that shouldn't make any difference (?).

Should I have expected to see something out of $_SESSION ?

Thanks for you help.......
 
As it happens, yes.

I ran into this issue when working on the CAPTCHA element the other day. Turns out that J! isn't using the standard PHP session, it handles it's own session storage. So you have to instantiate Joomla, so it can do it's thing and set the session up for you.

This is what I have to do in the CAPTCHA image.php file to get the 'security_code' from the session:

PHP:
$jpath = dirname(__FILE__);
$jpath = str_replace('/components/com_fabrik/plugins/element/fabrikcaptcha', '', $jpath);
define('JPATH_BASE', $jpath );

define( 'DS', DIRECTORY_SEPARATOR );

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();

if (empty($_SESSION['security_code'])) {
    exit;
}

Obviously you'll need to change the but where I define JPATH_BASE to suit your situation, and you won't be looking for 'security_code', but the above code should be enough for you to get going with.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top