Appnitro Software Forums » MachForm 2

Dynamic content (PHP)


  1. markjames
    Member

    I've gotten all of this to work, however when I use PHP integration i cannot get the email to autofill, everything else does. When I just use the standard view.php version of the form it pulls the data without any issues.

    Posted 2 years ago #
  2. markjames, this might depends on how your current system handle GET requests.

    Are you using any kind of CMS?

    Also, can you let us know more details about your form and page URL? along with the parameters.

    Send to: customer.service [at] appnitro.com


    MachForm Founder

    Posted 2 years ago #
  3. markjames
    Member

    I used this

    if($form_id == 1 && $row['element_id'] == 9){
    $element[$j]->default_value = $_GET['email'];
    }

    (of course with my form values, form 1 and element 9.) I'm new to the MachForm software but my client had it on their domain and I'm starting to like it, sure makes my job much easier. Just trying to figure out why the email wont pass through.

    on view.php?id=1&first=FirstName&last=LastName&email=email@mail.com

    it works flawlessly but when I try to integrate it using the PHP integration code the only variables that pass/work are first and last.

    Posted 2 years ago #
  4. ano
    Member

    A more universal way of modifying the display_simple_name function to set the default values for those fields.
    Put this code into the beginning section of display_simple_name() function:
    backticks
    $name = str_replace(' ', '_', $element->title);

    if(!empty($_GET['First_'.$name])){
    $element->populated_value['element_'.$element->id.'_1']['default_value'] = trim($_GET['First_'.$name]);
    }

    if(!empty($_GET['Last_'.$name])){
    $element->populated_value['element_'.$element->id.'_2']['default_value'] = trim($_GET['Last_'.$name]);
    }
    backticks

    Now, any parameter that you pass in the query string will automatically populate the Name using the following format:

    For first name = First_[field_title]<br>
    For last name = Last_[field title]<br>.

    If your field title contains spaces, you can pass the query string parameter using underscores in place of the spaces and it will work fine.

    Posted 2 years ago #
  5. M202A1
    Member

    Can you guys show examples of what you are working on?

    Posted 2 years ago #
  6. shaungummere
    Member

    I'm not sure if this thread is still active, but I'm having the same issue that markjames is having above. The fields will fill in properly on the standalone form (the view.php page) but once embeded via php include into another page, only the name fields will fill in. Any help would be much appreciated!

    Posted 2 years ago #
  7. Hi shaun,

    As my reply above, if you are embedding the form using the php include (advanced form code) instead of the iframe code, then it would depends on your current system/cms.

    Your current CMS might filtered those parameters, hence MachForm didn't get it.
    The easiest way is to use the iframe code to embed the form.


    MachForm Founder

    Posted 2 years ago #
  8. shaungummere
    Member

    Thanks, yuniar. I found that I had only added bkonia's universal code to the display_form function but it also needed to be added to the display_integrated_form function on line 2020. Seems to be working as expected now!

    Posted 2 years ago #
  9. Just a note for anyone else that does not realise this (Took me a while to figure it out). If you are using the Advanced Form Code to integrate you form into your site then you must add yuniar's code at around line 2023 in view_functions.php and not at line 1682.

    You still place your code exactly below the line:
    $element[$j]->default_value = htmlspecialchars($row['element_default_value']);

    So

    Line 1682 for external forms and line 2023 for Advanced Form Code.

    I know the previous post says pretty much the same thing but this is an idiots guide for any other people like me that read this thread.

    Posted 1 year ago #
  10. zerokom
    Member

    When using the Advanced Form Code (PHP), how do I pass the additional parameters to machform?

    <?php
    require("/foo.bar/machform/machform.php");
    $mf_param['form_id'] = 6;
    $mf_param['base_path'] = 'http://foo.bar/machform/';
    display_machform($mf_param);
    ?>

    The only parameter passed with the Advanced Form Code appears to be that of the form_id

    Posted 1 year ago #
  11. There are no other parameters available for the advanced code other than the form id and the base path.

    If you would like to add another custom parameters, you can simply pass it into the $mf_param array.

    Something like:

    $mf_param['my_new_param'] = 'this is my custom parameters';

    You can then use this param within the "display_machform()" function, which is located inside machform.php file.


    MachForm Founder

    Posted 1 year ago #
  12. ano
    Member

    Here is the universal/generic code for pre-populating drop down lists. In include/view-functions.php look for this line:

    $option_markup .= "<option value=\"{$option->id}\" {$selected}>{$option->option}</option>\n";

    ABOVE that line add the following code:

    $select = str_replace(' ', '_', $element->title);
    if (isset($_GET[$select]) && $option->option == $_GET[$select]){
    $selected = 'selected="selected"';
    }

    Remember spaces get replaced with underscores. So for example in a form with id 1 and a field called Email To you would have:

    http://yourwebaddress/machform/view.php?id=1&Email_To=your@emailaddress.com

    to pre-populate the Email To field with your@emailaddress.com. The same principal can be applied to checkboxes and radio buttons.

    Posted 1 year ago #
  13. I'm trying to do something similar here, and if I could add PHP as 'default' text, I'd be done.

    So, Is there a way to populate text fields with a default value to show PHP such as echo $_SERVER['QUERY_STRING'];

    Posted 1 year ago #
  14. I'm afraid it won't be possible to put PHP code into the default value from within the admin panel.

    However, this can be done by doing a hardcode into the PHP file.
    It is pretty much similar as the modification posted on the first page.

    Let me know what do you need exactly, and I'll show you the code.


    MachForm Founder

    Posted 1 year ago #
  15. Where do I change the form id?

    Quoting this post:

    "Hi sk,

    I'll try to help you with this.

    Let's take a sample with this form:
    http://www.appnitro.com/demo/view.php?id=5

    Let say our goal is to populate the email field, so the url would be like this:
    http://www.appnitro.com/demo/view.php?id=5&email=test@example.com

    Now, our form_id is 5 and the email input field is having id element_3 (view source to see it).

    So, what you need to do is, edit your view-functions.php file, on line 1682 you will find this code:

    $element[$j]->default_value = htmlspecialchars($row['element_default_value']);

    Right below that line, add this code:

    if($form_id == 5 && $row['element_id'] == 3){
    $element[$j]->default_value = $_GET['email'];
    }

    Save the file and you should be all set.
    Of course you will need to adjust those form id and element id number.

    I hope I'm being clear for you. Feel free to post any questions. "

    Posted 1 year ago #
  16. Reply to dexter666

    You ADD the three lines to view-functions.php below the line:

    $element[$j]->default_value = htmlspecialchars($row['element_default_value']);

    Lines to enter:

    $form_id == <FORM ID HERE> && $row['element_id'] == <ELEMENT ID HERE>){
    $element[$j]->default_value = $_GET['email'];
    }
    If you are having difficulty, maybe you should tell us what you are trying to achieve and provide your form/element numbers. That way we can post the answers for you with no amendments required.

    Posted 1 year ago #
  17. Hi,

    Yes that one I did, thanks. and I know it works because when I add manually &email=test@example.com to the url the email filed populates. But at the end of that post, Yuniar said:

    "Of course you will need to adjust those form id and element id number."

    How to change the id form to display in the url like this http://www.mysite.com/demo/view.php?id=5&email=test@example.com, instead of this: http://www.mysite.com/demo/view.php?id=5

    Thanks in advance Trowar!

    Posted 1 year ago #
  18. You must link to the form from another page using that link (http://www.mysite.com/demo/view.php?id=5&email=test@example.com) and then the form will take the email address from the link.

    What are you trying to achieve exactly?

    If you manually add &email=test@example.com and it auto populates then the code is working as intended.

    Posted 1 year ago #
  19. DeadLikeMe
    Member

    Hello,
    ive got a question,

    i am displaying my form using the Advance Code which i placed into a php page

    i added this:

    <?php
    require("/srv/www/vhosts/httpdocs/mail/machform.php");
    $mf_param['form_id'] = 3;
    $mf_param['base_path'] = 'http://www.domain.com/mail/';
    $mf_param['element_1'] = '<?php echo $slname; ?>';
    display_machform($mf_param);
    ?>

    I wanted to autofill the first Field of my Form with the username of my member. so i added


    $mf_param['element_1'] = '<?php echo $slname; ?>';

    to my advanced code.

    then, how someone posted i edited view-functions.php
    and put after line 1682

    if($_GET['id'] == 5){

    if(!empty($_GET['first'])){
    $element->populated_value['element_'.$element->id.'_1']['default_value'] = trim($_GET['first']);
    }

    }

    but my form field stays empty :(

    how can i pass the username into the form?

    Posted 1 year ago #
  20. Hi, Sorry I'm not getting this exactly.

    I have Form id=1 that has many elements including 'email'.
    I want to create a new form id=2 with just one element to collect the users email addy and pass that to form 1 using the redirect url or other method.

    The idea is to have the user input their email to gain access to the main form but not have to re-enter it when they get there.

    I'm running version 2.3

    Posted 1 year ago #

RSS feed for this topic

Reply »