The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 783 errorHandler->error
/showthread.php 26 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 783 errorHandler->error
/showthread.php 26 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/showthread.php 26 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 909 errorHandler->error
/showthread.php 26 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/showthread.php 26 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/showthread.php 26 require_once
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key "mybb" - Line: 1952 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1952 errorHandler->error
/inc/functions_indicators.php 41 my_set_array_cookie
/showthread.php 629 mark_thread_read
Warning [2] Undefined property: MyLanguage::$ratings_update_error - Line: 5 - File: showthread.php(732) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/showthread.php(732) : eval()'d code 5 errorHandler->error
/showthread.php 732 eval
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "invisible" - Line: 1506 - File: showthread.php PHP 8.1.27 (Linux)
File Line Function
/showthread.php 1506 errorHandler->error
Warning [2] Undefined variable $threadnotesbox - Line: 30 - File: showthread.php(1533) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/showthread.php(1533) : eval()'d code 30 errorHandler->error
/showthread.php 1533 eval
Warning [2] Undefined variable $addremovesubscription - Line: 79 - File: showthread.php(1533) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/showthread.php(1533) : eval()'d code 79 errorHandler->error
/showthread.php 1533 eval



FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
update fields after failed validation
#1
Hi,

I followed the "Adding our validation" tutorial and it works well. My problem is that when the validation failed, some fields are not updated (the menu type and text area).
Is there a way to have all fields updated?

Thanks
Reply
#2
Hi tfm,

Welcome to the forums! Smile

This is with PHP validation, I take it? Could you post your PHP code so I could take a look at it?

- Ben
Reply
#3
Hi Ben and thanks in advance to take a look at my code.

PHP Code:
<?php require_once("/home/a5060614/public_html/formtools_2.1.0._Beta/global/api/api.php");
$fields ft_api_init_form_page(6);

// validation time!
$errors = array();
if (isset(
$_POST['Submit']))
{
  
$rules = array();
  
$rules[] = "required,nom,Veuillez entrer votre nom";
  
$rules[] = "required,email,Veuillez entrer votre adresse email";
  
$rules[] = "valid_email,email,Veuillez entrer une adresse email valide";
  
$rules[] = "required,code_postal,Veuillez indiquer votre code postal";
  
$rules[] = "digits_only,code_postal,Votre code postal ne doit comporter que des chiffres";
  
$rules[] = "required,pays,Veuillez indiquer votre pays";
  
$rules[] = "required,type,Veuillez indiquer le type de travaux que vous désirez";
  
$rules[] = "required,delai,Veuillez indiquer le délai que vous désirez";
  
$errors validate_fields($_POST$rules);
 
  
// no errors - great! Now we process the page. The ft_api_process_form does
  // the job of both updating the database and redirecting to the next page
  
if (empty($errors))
  {
    
$params = array(
      
"submit_button" => "Submit",
      
"next_page" => "Merci.php",
      
"form_data" => $_POST,
      
"file_data" => $_FILES,
      
"finalize" => true
    
);
    
ft_api_process_form($params);
  }
  
// it failed validation. Update $fields with the latest contents of the form data
  
else 
  {
    
$fields array_merge($_SESSION["form_tools_form"], $_POST);
  }
}
?>
Reply
#4
Hi tfm,

Ah! The problem actually turned out to be just with the markup.

Dropdowns all need to have value="" attributes for the options. In the absence of the value attribute, some browsers send along whatever the content of the option tag is, but it's not standardized. So change this:

Code:
<select name="delai" id="delai">
  <option />
  <option>1 semaine</option>
  <option>1 mois</option>
  <option>Plus</option>
</select>

To this:

Code:
<select name="delai" id="delai">
  <option value=""></option>
  <option value="1 semaine">1 semaine</option>
  <option value="1 mois">1 mois</option>
  <option value="Plus">Plus</option>
</select>

Then, add in the PHP code to have it re-filled:

Code:
<select name="delai" id="delai">
  <option value="" <?php if (@$fields["delai"] == "") echo "selected"; ?>></option>
  <option value="1 semaine" <?php if (@$fields["delai"] == "1 semaine") echo "selected"; ?>>1 semaine</option>
  <option value="1 mois" <?php if (@$fields["delai"] == "1 mois") echo "selected"; ?>>1 mois</option>
  <option value="Plus" <?php if (@$fields["delai"] == "Plus") echo "selected"; ?>>Plus</option>
</select>

For the textarea, don't bother with the value="" attribute. To re-fill a textarea, you need to output th content right within the tag itself:

Code:
<textarea name="description" cols="50" rows="5" id="description"><?php echo @$fields["description"]; ?></textarea>

Hope this helps -

Ben

Reply
#5
Thanks a lot but I still have one problem.
It works well for the text area but with the dropdowns, I have a syntax error when I add the php code. At the same time, it creates an error in the textarea section... Do I have to add something before the php code?
Reply
#6
Hi tfm,

Sorry for the long wait in responding!

Could you post the HTML and PHP for your dropdown here? It's probably just a small little syntax error in the code.

- Ben
Reply
#7
Hi Ben,

Here is all the php code I used :
PHP Code:
<?php require_once("/home/a5060614/public_html/formtools_2.1.0._Beta/global/api/api.php");
$fields ft_api_init_form_page(2);

// validation time!
$errors = array();
if (isset(
$_POST['Submit']))
{
  
$rules = array();
  
$rules[] = "required,nom,Veuillez entrer votre nom / Please enter your name";
  
$rules[] = "required,email,Veuillez entrer votre adresse email / Please enter your email address";
  
$rules[] = "valid_email,email,Veuillez entrer une adresse email valide / Please enter a valid email address";
  
$rules[] = "required,code_postal,Veuillez indiquer votre code postal / Please enter your zip code";
  
$rules[] = "digits_only,code_postal,Votre code postal ne doit comporter que des chiffres / Your zip code should only contain digits";
  
$rules[] = "required,pays,Veuillez indiquer votre pays / Please enter your country of residence";
  
$rules[] = "required,type,Veuillez indiquer le type de travaux que vous désirez / Please enter the kind of work you want";
  
$rules[] = "required,delai,Veuillez indiquer le délai que vous désirez / Please enter the deadline for your work";
  
$errors validate_fields($_POST$rules);
 
  
// no errors - great! Now we process the page. The ft_api_process_form does
  // the job of both updating the database and redirecting to the next page
  
if (empty($errors))
  {
    
$params = array(
      
"submit_button" => "Submit",
      
"next_page" => "Merci.php",
      
"form_data" => $_POST,
      
"file_data" => $_FILES,
      
"finalize" => true
    
);
    
ft_api_process_form($params);
  }
  
// it failed validation. Update $fields with the latest contents of the form data
  
else 
  {
    
$fields array_merge($_SESSION["form_tools_form"], $_POST);
<
select name="delai" id="delai">
  <
option value="" <?php if (@$fields["delai"] == "") echo "selected"?>></option>
  <option value="1 semaine" <?php if (@$fields["delai"] == "1 semaine") echo "selected"?>>1 semaine</option>
  <option value="1 mois" <?php if (@$fields["delai"] == "1 mois") echo "selected"?>>1 mois</option>
  <option value="Plus" <?php if (@$fields["delai"] == "Plus") echo "selected"?>>Plus</option>
</select>
  }
  
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr-fr">
<head> 
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
    <title>Demande de devis</title>    
      <link media="all" type="text/css" rel="stylesheet" href="CommTat.css" />
</head>

<body>



<?php // if $errors is not empty, the form must have failed one or more validation 
// tests. Loop through each and display them on the page for the user
if (!empty($errors))
{
  echo 
"<div class='error'>Veuillez résoudre les erreurs suivantes :\n<ul>";
  foreach (
$errors as $error)
    echo 
"<li>$error</li>\n";
 
  echo 
"</ul></div>"
}

?>

The "<select name="delai" id="delai">" line indicates a syntax error. I tried to put it somewhere else with the same result...

Here is the html for the dropdown :
Code:
<select name="delai" id="delai">
        <option value=""></option>
    <option value="1 semaine">1 semaine</option>
    <option value="1 mois">1 mois</option>
    <option value="Plus">Plus</option>
</select>

Thanks once again
Reply
#8
Hi tfm,

Ah! Yeah, it's this bit. Change these lines:

Code:
// it failed validation. Update $fields with the latest contents of the form data
else
{
$fields = array_merge($_SESSION["form_tools_form"], $_POST);
<select name="delai" id="delai">
<option value="" <?php if (@$fields["delai"] == "") echo "selected"; ?>></option>
<option value="1 semaine" <?php if (@$fields["delai"] == "1 semaine") echo "selected"; ?>>1 semaine</option>
<option value="1 mois" <?php if (@$fields["delai"] == "1 mois") echo "selected"; ?>>1 mois</option>
<option value="Plus" <?php if (@$fields["delai"] == "Plus") echo "selected"; ?>>Plus</option>
</select>
}

}

To this:

Code:
// it failed validation. Update $fields with the latest contents of the form data
else
{
$fields = array_merge($_SESSION["form_tools_form"], $_POST);
?>
<select name="delai" id="delai">
<option value="" <?php if (@$fields["delai"] == "") echo "selected"; ?>></option>
<option value="1 semaine" <?php if (@$fields["delai"] == "1 semaine") echo "selected"; ?>>1 semaine</option>
<option value="1 mois" <?php if (@$fields["delai"] == "1 mois") echo "selected"; ?>>1 mois</option>
<option value="Plus" <?php if (@$fields["delai"] == "Plus") echo "selected"; ?>>Plus</option>
</select>
<?php
}

}

- Ben
Reply
#9
Hi Ben,

Thanks, the error disappeared but my fields were still blank after a submitted error.
I looked again through various websites and I have found a solution I missed before. Here it is for those who will be interested:

I replaced :
Code:
<select name="delai" id="delai">
  <option value=""></option>
  <option value="1 semaine">1 semaine</option>
  <option value="1 mois">1 mois</option>
  <option value="Plus">Plus</option>
</select>
by
Code:
<select name="delai[]" id="delai">
  <option value="" <?php if (@in_array("", $fields["delai"])) echo "selected"; ?>></option>
  <option value="1 semaine" <?php if (@in_array("1 semaine", $fields["delai"])) echo "selected"; ?>>1 semaine</option>
  <option value="1 mois" [quote]<?php if (@in_array("1 mois", $fields["delai"])) echo "selected"; ?>>1 mois</option>
  <option value="Plus" <?php if (@in_array("Plus", $fields["delai"])) echo "selected"; ?>>Plus</option>
</select>

And I didn't need the additional code in the php section.

Thanks for your time
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)