This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

How to limit access to redirect page, after submission?


  1. MvdL79
    Member

    Hi Yuniar,

    I have a question regarding the Form Properties; you can show a customer, who has submitted the form, a succes message. Here you have two options; "Show text" and "Redirect URL".

    I want to use the "Redirect URL"-option to send the customer to a succesfull submission PHP. Of course this is very easy to do, however I want to limit access to this PHP page, so outsiders (= people who have not filled in the form) cannot access this page.

    How do I this?

    Also is it possible to display some of the information which has been filled in on the forms on this succesfull submission page? E.g. the name of the person?

    Full example:
    Customer fills in the form and submits it.
    Person gets redirected to a page called submitted.php.

    submitted.php show the following:

    Dear Sir / Madam {name},

    Thanks for filling in the form. The form has been sent to our office.
    etc. etc. etc.

    Hopefully you understand what I mean... :)
    ...I tried to explain the best I could.

    Posted 15 years ago #
  2. MvdL79
    Member

    Please advice.

    Posted 15 years ago #
  3. AMurray
    Pro Member

    I'm not sure Machform is designed to customise the "thank you/successful submission" page (other than a redirect to a normal HTML page, or simple message) in the way you describe.

    However version 2.0 has an auto-responder email feature, which can be customised to do basically the same thing.

    What you could do, is have your thank you page "Thank you for your submission. An email has been sent to the email address provided with a copy of the data you have submitted".

    At least then, they can go to their email and retrieve a copy of the information - it's the same thing you're asking except Machform sends it to the user by email, rather than displaying it in a web page (PHP page). Machform can also send you (or other specified person/s) a copy of the submission in addition to the user of the form.

    Version 2 has a revamped auto-responder,so you might consider upgrading if you don't already use ver 2.0 (you don't mention which you do use).

    Maybe it is possible to do exactly what you're after, but not without some possible modification of code. It may well be added as a feature to the next release of Machform.

    As far as your concern over someone browsing directly to the thanks page, I don't think that should be a worry, as I would think the success page would be linked somehow, to the form being submitted or even generated by the script at run-time so the page displays the submission data, and vanishes into cyberspace when the browser is closed, and can't be re-accessed or browsed to directly.

    The data from the form would probably be passed to the php page for your success message by temporary variables, or cookies etc which would be deleted once the browser is closed, or the user navigates to another page of the site or visits another website.

    Posted 15 years ago #
  4. MvdL79
    Member

    Well sending an email is not a solution, since they already get an automatic email.
    I want the client to see that the PHP I am going to code along with the use of the form's data e.g. name etc.

    I have the latest version (unlimited license).

    So hopefully Yuniar can advice or help me here...

    Posted 15 years ago #
  5. MvdL79
    Member

    If it's to difficult, or to much work. I will create a general PHP page. No problem.

    Posted 15 years ago #
  6. yuniar

    Sorry for the late response. We're having national holidays here, for the last two days (and few more days) :-)

    I'll try to write you some hack within the next hours.


    MachForm Founder

    Posted 15 years ago #
  7. yuniar

    Ok, actually it's pretty simple. Basically, you only need to put all your form data into temporary session variable and then access it from your submitted.php page.

    First, to save your form submission data to session variable, edit your includes/post-functions.php file, search around line 1170 for this code:

    $process_result['status'] = true;

    right under that line, insert this code:

    $_SESSION['is_valid_user'] = true;
    $_SESSION['form_data'] = $table_data;

    That would store your form data into a variable called $_SESSION['form_data']

    You can then access the content of $_SESSION['form_data'] from submitted.php

    Some example:

    echo 'Dear Sir/Madam '. $_SESSION['form_data']['element_2'];

    on the above element_2 is just a sample, you should replace it with your own field id.

    To see the whole content of that variable, just do this code:

    print_r($_SESSION['form_data']);

    you'll get a complete list of your form data.


    MachForm Founder

    Posted 15 years ago #
  8. yuniar

    Now, to limit access to that page. Simply add this code at the very top of your submitted.php file:

    <?php
    	session_start();
    	if($_SESSION['is_valid_user'] !== true){
    		die("You are not authorized to see this page");
    	}
    ?>

    MachForm Founder

    Posted 15 years ago #
  9. MvdL79
    Member

    Hi Yuniar!

    The delay is no problem at all!
    ...just make sure you enjoy your holidays! :)

    I will give the code a go as soon as possible. Thanks! :D

    Posted 15 years ago #
  10. gordonm
    Member

    Hi Yuniar

    I want to do something similar, although my form is pretty much all dropdown lists... the session data available is in index form rather than the drop down text. How could I approach that one?

    Posted 15 years ago #
  11. redityo

    Hi,

    It seems you need to add more code on "include/post-functions.php" to get drop down text. First you have to change these lines :

    $_SESSION['is_valid_user'] = true;
    $_SESSION['form_data'] = $table_data;

    replace with

    $_SESSION['is_valid_user'] = true;
    
    $new_table_data = array();
    foreach ($table_data as $key=>$value) {
    	if ($key == 'element_6')
    		$new_table_data[$key] = get_dropdown_text($form_id,'6',$value);
    	elseif ($key == 'element_7')
    		$new_table_data[$key] = get_dropdown_text($form_id,'7',$value);
    	else
    		$new_table_data[$key] =  $value;
    }
    
    $_SESSION['form_data'] = $new_table_data;

    after that you can insert these code between line 10

    function get_dropdown_text($form_id,$element_id,$value_id) {
    	$strsql = "select ~option~ from ap_element_options
    			   where form_id = '" . $form_id . "'  and
    					 element_id = '" . $element_id . "' and
    					 option_id = '" .$value_id . "' ";
    
    	$result = do_query($strsql);
    	$row =  do_fetch_result($result);
    	return  $row[0];
    }

    MachForm Support

    Posted 15 years ago #
  12. gordonm
    Member

    Wow! Your support is second to none.

    Thank you very much will add in the code, thats helped me out so much.

    Thanks again

    Posted 15 years ago #
  13. yuniar

    This forum can't display backticks, so make sure to replace the "~" characters to backticks in this line:

    select ~option~ from ap_element_options

    MachForm Founder

    Posted 15 years ago #
  14. tundeogidi
    Member

    Please could you help with a code to create a submitted.php file to diaplay the following;
    ---------------------
    Dear (Full Name),

    Thank you for your form submission, your form number is (entry_no).

    Regards
    ---------------------

    Help me with the code so I can simply copy and paste in Dereamweaver to create a page called submitted.php which use will be redirect to after form submission.

    Posted 13 years ago #
  15. yuniar

    Have you tried doing the above code? Was there any errors?


    MachForm Founder

    Posted 13 years ago #
  16. tundeogidi
    Member

    I can only see the message below after submitting the form.

    'You are not authorized to see this page'

    My submitted.php page content is pasted below;

    <?php
    session_start();
    if($_SESSION['is_valid_user'] !== true){
    die("You are not authorized to see this page");
    }

    print_r($_SESSION['form_data']);
    ?>

    Posted 13 years ago #
  17. redityo

    The codes seems fine, it should works. It might be you've put $_SESSION['form_data'] into the wrong line in post-functions.php file.
    For the latest version (2.3), you can go to line 1216 for this code :

    $process_result['status'] = true;

    then put these code bellow that line

    $_SESSION['is_valid_user'] = true;
    $_SESSION['form_data'] = $table_data;

    However, if the problem still persist, you can send us your "post-functions.php" and "submitted.php" file to

    customer.service[at]appnitro.com

    I will check it


    MachForm Support

    Posted 13 years ago #
  18. discosteve
    Member

    I know this forum is from a while back, but I'm trying to get this to work for one of my forms. Several of the fields are checkboxes and radio buttons and I'm trying to modify the code redityo gives for the dropdown fields to work with checkboxes and radio buttons. So far I can't get it to work properly. Any chance someone can help me out and detail the php code I would need to use to get checkboxes and radio buttons to store to the session variable and display the chosen button on the results page?

    Thanks!

    Posted 13 years ago #
  19. yuniar

    discosteve -- the code should be the same as the one posted by redityo above.

    However, the code posted above doesn't seems to be displayed properly.
    Check this code:

    "select ~option~ from ap_element_options

    change the ~ character with backtick.

    If the problem persist, you can contact us directly via email and send us your modified files. We'll check it. Make sure to let us know the URL to your form as well.


    MachForm Founder

    Posted 13 years ago #
  20. brightmyer
    Member

    If I wanted to create a link on the "Thank you for submitting" page to the actual results, how would I do that? The main form fiemds will be text fields. I am looking for a way to display the results of a survey (Name, Item you are bringing, etc.) in a list so people can see real time results. Is this doable? I would like to embed the results into a webpage.

    Thanks!

    Posted 13 years ago #

RSS feed for this topic

Reply »