Jump to content

rickphp

Members
  • Posts

    27
  • Joined

  • Last visited

Posts posted by rickphp

  1. I am currently making a php contact form, and i have various validation checks being ran, and when an error is found the data the user inputted was being lost because the page is refreshing. I managed to resolve the issue by using the coding below for input fields but I can't manage to make drop down boxes retain the selected option when the page is refreshed, any help please?

     

    <?php
    session_start();
    ?>

     

      if ($submit) {
    
      foreach($_POST as $key=>$value){
        $_SESSION[$key]=$value;
      }

     

    Here is an example of how the data is retained in a normal input field.

     

    <input class="form" name="name1" type="text" size="26" maxlength="20" value="<? print("$_SESSION[name1]");?>" />

     

    But I can't figure out how to do the same for the drop down boxes? Below is the html code for the drop down box. Any help please?

     

    <select class="form"  name="customer"><option value="Select One">Select One</option><option value="Yes">Yes</option><option value="No">No</option></select>

     

    Thank you!

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.