Form Tools
[FIXED] non-valid entries return empty form - Printable Version

+- Form Tools (https://forums.formtools.org)
+-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1)
+--- Forum: API (https://forums.formtools.org/forumdisplay.php?fid=17)
+--- Thread: [FIXED] non-valid entries return empty form (/showthread.php?tid=196)



[FIXED] non-valid entries return empty form - sergiozambrano - Jun 30th, 2009

All fields are empty when validation returns the form to the first (the one) page.
Thank you page is displayed correctly and submission is successful if form is validated.

Error message shows fine. You can see it working at http://seosumo.com/who-we-are/contact (it's an iframe, because self-submitting the form didn't work due to permalinks / rewrite on wordpress page)

my form is

PHP Code:
<?php
require_once("FormTools/global/api/api.php");

$errors = array();
if (isset(
$_POST) && !empty($_POST))
{
  
$rules = array();
  
$rules[] = "required,name,Please enter your name.";
  
$rules[] = "required,email,Please enter your email address.";
  
$rules[] = "valid_email,email,Please enter a valid email address.";
  
$errors validate_fields($_POST$rules);
}

if (empty(
$errors))
{
$fields ft_api_init_form_page(9);
$params = array(
  
"submit_button" => "contact_submit",
  
"next_page" => "thankyou.php",
  
"form_data" => $_POST,
  
"finalize" => true
    
);
ft_api_process_form($params);
}
?>
---------------------------------------------------
<div id="contactform_div">
  <?php
  
if (!empty($errors))
  {
    echo 
"<div class='error'>Please correct the following errors, and resubmit the form:"
       
"<ul>";
    foreach (
$errors as $error)
      echo 
"<li>$error</li>";
  
    echo 
"</ul></div><br />"
  }
  
?>
  <form id="contactform" action="<?php echo $_SERVER["PHP_SELF"]?>" method="post" onsubmit="contactform_processing()">
<label>Name:<input name="name" type="text" id="name" value="<?=@$fields['name']?>" size="35" /></label>
<label>E-Mail:<input name="email" type="text" id="email" value="<?=@$fields['email']?>" size="35" /></label>
<label>Comments:<br /><textarea id="comments" cols="40" rows="10" name="comments"><?=@$fields['comments']?></textarea></label>
<input name="report" id="report" value="1." <?php if (@$fields['report'] == '1') echo '1'?> type="checkbox"> 
<span class="warningred">I want my FREE SEO Preliminary Report *</span>
<label>Website:<input name="website" type="text" value="<?=@$fields['website']?>" size="35"></label>
<?php ft_api_display_captcha(); ?><input type="submit" value="Submit" name="contact_submit"> 



RE: non-valid entries return empty form - sergiozambrano - Jul 1st, 2009

I forgot…
Error messages (validation) work fine. They are there when the page is reloaded, and even before and while the non-valid form is submitted. When the page refreshes the content is gone.


RE: non-valid entries return empty form - sergiozambrano - Jul 4th, 2009

Any ideas how to prevent the form to be cleared when validations brings me back to the form?


[STILL NOT WORKING] - sergiozambrano - Aug 14th, 2009

Followed the instrucions here http://forums.formtools.org/showthread.php?tid=215
no success.

New code stilll submits if everything is fine, but returns an empty form from invalid submissions. Form is filled in ONLY when page is left and re-browsed.

PHP Code:
<?php
require_once("LeadsManager/global/api/api.php");
$fields ft_api_init_form_page(9);

$errors = array();
if (isset(
$_POST['contact_submit'])) {
  
$rules = array();
  
$rules[] = "required,name,Please enter your name.";
  
$rules[] = "required,email,Please enter your email address.";
  
$rules[] = "valid_email,email,Please enter a valid email address.";
  
$errors validate_fields($_POST$rules);

if (empty(
$errors)) {

    
$params = array(
      
"submit_button" => "contact_submit",
      
"next_page" => "thankyou.php",
      
"form_data" => $_POST,
      
"finalize" => true
    
);
    
    
ft_api_process_form($params);
    }




RE: non-valid entries return empty form - Ben - Aug 16th, 2009

Hi Sergio,

Sorry you're still having trouble with this. As mentioned in another post on the same topic, I wasn't able to get to the bottom of it - for some reason process.php isn't setting sessions on your server. If this is an absolute show-stopper for you, email me at ben.keen@gmail.com with your FT, form URL and Form Tools login information and I'll see if I can find out anything more.

Just a warning, though - I'm REALLY busy these days, so it may take a little time to get to it.

- Ben


[SOLVED] - sergiozambrano - Aug 18th, 2009

Here's the solution right from Ben Keen

http://forums.formtools.org/showthread.php?tid=243&pid=1009#pid1009