0

hello i created a form in front via a plugin in my tmpl i create a file value_form.php (compatible with the component)

<form id="contact-form-'.$formid.'" method="POST" class="form-validate" enctype="multipart/form-data">
    <fieldset>
        '.$titleformD.'
        '.$fields_display.'
        '.$consent_field.'
        '.$captcha_html.'
    <div class="form-group control-group submit-button">
    <input type="submit" name="submit" value="'.JText::_('FLEXI_FIELD_EMAIL_SUBMIT_LABEL_VALUE').'" class="'.$submit_class.'">
    </div>
    <input type="hidden" name="emailtask" value="plg.email.submit" />
    <input type="hidden" name="formid" value="'.$formid.'" />
    <input type="hidden" name="emailauthor" value="'.$addr.'" />
    <input type="hidden" name="itemid" value="'.$item->id.'" />
    <input type="hidden" name="itemtitle" value="'.$item->title.'" />
    <input type="hidden" name="itemalias" value="'.$item->alias.'" />
    <input type="hidden" name="itemauthor" value="'.$item->author.'" />
    <input type="hidden" name="catid" value="'.$item->catid.'" />
    <input type="hidden" name="return" value="" />
    '.JHtml::_("form.token").'
    </fieldset>
    </form>

and i need to get the value in my 'helper' email.php i do this

$id = $jinput->post->get('formid', '', '');
$datas = $jinput->post->get($id, array(), 'array');

and to get value

$fromemail = $datas['emailfrom'];

but this value is already empty i have value of my form if field aren't hidden type ....

enter image description here

enter image description here

thanks for any help

2
  • SUPERGLOBALs are keyed by the field's name, not by a substring in the table's id attribute. Why not try to access the hidden input fields' values by name attribute?
    – mickmackusa
    Jun 19 at 8:26
  • hello sorry i don't understand your reply, can you explain more ? Jun 19 at 20:01
1

The $_POST array structure is determined by the name attribute of each field which exists inside of the <form></form> tags.

All of the basics are here: https://docs.joomla.org/Retrieving_request_data_using_JInput

The array option is appropriate when you have brace-syntax in the field's name to express a nested structure on the field's submission data. example

Although Joomla does have getArray(), I recommend that you systematically grab the field values individually and include the default value and sanitisation technique when accessing the data.

From docs: $input->post->get(param_name, default_value, filter);

In practice:

$emailTask   = $input->post->get('emailtask', '', 'CMD');
$formId      = $input->post->get('formid', '', 'WORD');
$emailAuthor = $input->post->get('emailauthor', '', 'RAW'); // because stripping tags can potentially damage fringe case email addresses; use additional sanitisation step before using this value
$itemId      = $input->post->get('itemid', '', 'INT');
$itemTitle   = $input->post->get('itemtitle', '', 'STRING');
$itemAlias   = $input->post->get('itemalias', '', 'STRING');
$itemAuthor  = $input->post->get('itemauthor', '', 'STRING');
$catId       = $input->post->get('catid', '', 'INT');
$return      = $input->post->get('return', '', 'RAW');

If your expected post data isn't even making it to the destination where you expect it, then your issue is not in receiving the data, but sending it to the right place.

I don't know what is rendered by:

'.$titleformD.'
'.$fields_display.'
'.$consent_field.'
'.$captcha_html.'

so I don't know know if there is <form></form> inside of your form tags.

4
  • ok cool thanks for explain ! i replace $fromemail = $datas['emailauthor']; for $emailauthor = htmlspecialchars($_POST['emailauthor']); And that works ! Jun 21 at 7:35
  • If your problem is resolved, you may award the green tick to my answer to inform the system that your question is resolved.
    – mickmackusa
    Jun 21 at 7:43
  • Also, please take a moment to give yourself a more "human" screenname (unless you prefer to remain anonymous).
    – mickmackusa
    Jun 21 at 7:45
  • yes sorry i will do this thanks Jun 22 at 8:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.