Form Submit PHP script and Form Variables

Status
Not open for further replies.

JamesWilliams

New Member
Hi,

So, i'm curious about a few things that are probably common knowledge to PHP folks, hopefully you guys can point me in the right direction:

1. I would like to execute a number of PHP commands on a form submit (I assume using 'simple eval') like mkdir but would like to use elements of the form i.e. for example I would like to create a directory with the same name as the title - is this variable simply $title (assuming the element name is also 'title).

2. Also, I'd like to change the image upload directory to this new one. Any quick advice on this one?

3. I've read
http://fabrikar.com/index.php?option=com_smf&Itemid=9&topic=1629.0

Is this going to work for appending additional text to a text field?

Thanks in advance....
 
1. The form values are in the $aData[] array, with the array keys of the form table___element. So if it might look like $aData['jos_fabrik_formdata_2___title']. If in doubt, just look at the source of the form page, and find the element in question, it'll show you exactly what the name should be.

You also need to be very careful if you want to create a directly based on user input. Make sure there are no /'s or ..'s in it (so the user can't try and fool the script into creating directories elsewhere in your file system), and preferable replace spaces with an _.

Also, you won't have to create it yourself, as our upload routine will create the upload dir if it doesn't exist, as per step 2.

2. Yes, but it's a little trickier as you'll have to poke the value into the 'ul_directory' key in the correct element item array, within the $this->_groups structure. Something like ...

Code:
$this->_groups[$groupid]->$aElements[$elementid]->ul_directory = $new_upload_dir;

... where $groupid and $elementid are the numeric ID's of the group and element in question, and $new_upload_dir is the path you created in step 1. Note that this needs to be in the form images/stories/my_new_dir.

The eaisest way I know of identifying the numeric ID for the group and element you need is to go edit them in Fabrik admin, and see what the "cid=X" is set to on the URL.

3. Yes. Just reference the $aData[] array as in 1) above, like ...

Code:
$aData['jos_fabrik_formdata_2___some_element_name] .= " ... some extra text";

-- hugh
 
Status
Not open for further replies.
Back
Top