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
Redirect form to itself?
Started 15 years ago by tbenko | 6 posts |
-
I tried to create a PHP file, the form is redirected to,
In the PHP file displaying I would like to display some values from the submitted form.
But under the values, I would like to include the same form, so it could be submitted again if needed...
Question: is this possible? Any suggestions how to do this?
I think i have generated somehow an infinite loop or something cause on submit of the PHP included form the PHP shows empty page and keeps loading forever...
Thanks in advance.Posted 15 years ago # -
My PHP looks like this now (maybe this gives a clue what I did):
session_start();
if($_SESSION['is_valid_user'] == true){
//die("You are not authorized to see this page");
//better not die cause the form will not apear
//but only in this case we'll have the submitted data
echo "Session found";
//here comes whatever code i would like
} else {
echo "Session not found";
}
session_destroy();require("my_path");
$mf_param['form_id'] = myform_id;
$mf_param['base_path'] = 'my_base_path';
display_machform($mf_param);
Posted 15 years ago # -
Hi tbenko,
I'm not sure with your request, but maybe what you mean is getting a field value from submitted form, from previous submission. Let's try this customization, in here I assume you want to store a value from "text field" with element id = 1 in form 50 :
1. Edit "include/post-functions.php" and go around line 178, you will see this :
$table_data[$element_name] = $element_data;
add these code below that line
if($form_id == 50 && $element_id == 1) { $_SESSION["user_data"] = $element_data; }
2. Edit "includes/view-functions.php" and go around line 36 ~ 38, you will see this code :
if(isset($element->populated_value['element_'.$element->id]['default_value'])){ $element->default_value = $element->populated_value['element_'.$element->id]['default_value']; }
add these code below that line
if ($element->id == 1 && !empty($_SESSION['user_data'])) { $element->default_value = $_SESSION['user_data']; }
3. In your page, machform form will embedded something like this :
require("my_path"); $mf_param['form_id'] = myform_id; $mf_param['base_path'] = 'my_base_path'; display_machform($mf_param);
put this code in the end of embed code
unset($_SESSION["user_data"]);
Make sure you adjust the form and element id with yours
MachForm Support
Posted 15 years ago # -
Hi! Yes what I ment is is getting field values from previous submission. But when submitting the page that loads the form and should show results, the page does not load correctly in al browsers (ie. safari). Please try this address: http://lopottlaptop.hu/check.php.
I think the following code from the embedded form makes the page load forever:
<script type="text/javascript">top.location = '../check.php'</script>
Posted 15 years ago # -
Have you tried the above modifications?
MachForm Founder
Posted 15 years ago # -
Dear Yuniar!
Yes, I have tried. And I can get the value I need. My roblem is about the redirect function built in machform. When submitting the form everything works well in all browsers except SAFARI. For some reason SAFARI keeps loading the page forever. Can you please take a look at the demo page I made to see what I mean? Thank you.Posted 15 years ago #
Reply
You must log in to post.