4 Replies Latest reply on Jul 28, 2009 8:08 PM by Ian A.

    Passing a Parameter

    James_PT Level 1

      I have a form field on a form called ts_week.  It is a selection box of dates.  I'm select the date from the list box (ok), then click the submit button and want the form to pass the date value to the new screen as a parameter.  I've tried doing this by creating a DW Form variable but not doing it right.  The field name passes but the value is always blank (i.e., "ts_week =").  The code that DW generates is a $_POST['ts_week'] which again, shows the field name in the parameter list on the new screen but not the value.  This all occurs in a separate form on the page which is DW, not ADDT.

       

      I'm sure this is simple but I don't see it.

        • 1. Re: Passing a Parameter
          DwFAQ Level 4

          What is the extension of your page?

          You can't get $_POST value without <?php echo $_POST['ts_week']; ?> and the page needs .php extension.

           

           

           

           

           

          I have a form field on a form called ts_week.

           

           

          Is the form name 'ts_week' or is the form field id 'ts_week'?

          You need form field id to pass variable, not form name.

          • 2. Re: Passing a Parameter
            Ian A. Level 1

            You will have to make sure of two things:

            1) the form field has a name attribute, i.e. <input value="value here" name="first_name" type="text" size="40" maxlength="50" />  The id attribute in the input tag, is for Javascript to act upon, as well as for Cascading Style Sheets given the ID Selector "#" - the id attribute assigns a name to the element, and each id = "name" must be unique in a document.  The field name is for POSTing the data, (or GET if the form is set for that method).  The name and the id attribute names can be different.

             

            2) the page you are trying to echo back the form data must have a session started somewhere.  Depending on what you are using to create your page / site will determine whether you have to enter it yourself, or it is done for you in some scripting... ADDT normally has sessions started for you as far as I can tell.

             

            If you have to enter it yourself, at the top of the page, before any of the HTML/XHTML markup, put, <?php session_start(); ?>

             

            And yes, of course, it should have "php" as an extension. However, web servers can be set up to accept: .php4; .php3; .html; .htm; .shtml, and; .phtml amongst others to process php scripts.

            • 3. Re: Passing a Parameter
              DwFAQ Level 4
              2) the page you are trying to echo back the form data must have a session started somewhere.

               

              Why? The info is passed from form page to script using POST. There's no need to create a session for the data if it's only sent from one page. POST destroys the data after being passed to one page so if the field was not stored in the database on form action then it would need to be stored in a session or some other method in order to be passed to additional pages afterward. In this instance my understanding is that the data is being passed (or rather not being passed - hence the discussion) from form page to script page but the POST is not getting sent to form action script. If this is the case it's not a session problem I believe it's the reasons I've stated in the first post.

               

              That's great you believe php data will process on files without php extension. You can in fact use .htaccess in Apache to mask the extension of .php to .html or whatever you want and it will still process the php scripting. Thing is, you need to have an uploaded .php page on the server in the first place and .htaccess masks the extension from .php to .whatever. Bottom line if you have a php script on your page it's a good idea to have .php as the extension

              • 4. Re: Passing a Parameter
                Ian A. Level 1

                Sorry, my mistake, www.DwFAQ.info is 100% correct, I apologise to all.

                 

                If you were using Session variables, you would need to start the session... I am having problems with a remote server and ADDT scripting not setting session variables, and when set on another page, it will not unset the - it was on my brain when I replied.

                 

                Yes, the usual practice is to use *.php for file extension so may as well stick with that practice.

                 

                I might have to get some of your help www.DwFAQ.info regarding the problems I have with session variables, as that is still burnt into my brain.

                 

                Will start another topic about my problem.

                 

                I apologise once again about the misinformation regarding starting a session and post variables.