Menu

How to stay on the same page after refresh

Help
2008-04-18
2013-06-03
  • elearngroup

    elearngroup - 2008-04-18

    I am having multipage form, everything is working fine, but now i need to give clients a choice if they want to add more properties. So what I want is not to go to confirm.php page but when they click button "submit and add more" to stay on the same page with the same values from the last post. Reson is that 70% of the data is more-less the same so it will help and speed the proccess.

    Thank you

     
    • elearngroup

      elearngroup - 2008-04-18

      Sorry, I meant after submit.

      I am having multipage form, everything is working fine, but now i need to give clients a choice if they want to add more properties. So what I want is not to go to confirm.php page but when they click button "submit and add more" to stay on the same page with the same values from the last post. Reson is that 70% of the data is more-less the same so it will help and speed the proccess.

       
      • TNTEverett

        TNTEverett - 2008-04-18

        I have not used multi-page forms yet but I'm sure I can help.  Email me a link to your form and a copy of your processor.php file so I can have a look. 

         
        • elearngroup

          elearngroup - 2008-04-19

          hi, now this more then 2h but i just needed to go trough the form one more time to check that all ids are ok....

          here is a link to the form: http://www.waytostay.com/propform/index_v1.html

          and the processor.php is:

          [CODE]
          <?php

          $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));
          //$where_form_is = $_SERVER['PHP_SELF'];

          mail("ivagarfitt@gmail.com","Property Data Sheet of " . $_POST['owner_email'] . "","Form data:

          Address (Property): " . $_POST['property_address'] . "
          Floor No.: " . $_POST['property_floor_nr'] . "
          Door No.: " . $_POST['property_door_nr'] . "
          Postal Code (Property): " . $_POST['property_postal_code'] . "
          City: " . $_POST['property_city'] . "
          Neighbourhood: " . $_POST['property_neighbourhood'] . "

          Owners details:
          First name: " . $_POST['owner_first_name'] . "
          Surname: " . $_POST['owner_surname'] . "
          Address (Owner): " . $_POST['owner_address'] . "
          Postal Code (Owner): " . $_POST['owner_postal_code'] . "
          City: " . $_POST['owner_city'] . "
          Country: " . $_POST['owner_country'] . "

          Email address (Owner): " . $_POST['owner_email'] . "
          Phone: " . $_POST['owner_phone'] . "
          Mobile phone (Owner)): " . $_POST['owner_mobile_phone'] . "

          Arrival contact name: " . $_POST['contact_name'] . "
          Email address (Accommodation Management): " . $_POST['contact_email'] . "
          Mobile phone (Accommodation Management): " . $_POST['contact_mobile_phone'] . "
          Alternative Phone: " . $_POST['contact_alternative_phone'] . "

          Check-in: " . $_POST['check_in_time_hour'] . ":" . $_POST['check_in_time_minute'] . "
          Check-out: " . $_POST['check_out_time_hour'] . ":" . $_POST['check_out_time_minute'] . "
          Metro/bus station: " . $_POST['property_metro_bus'] . "
          Size : " . $_POST['property_size'] . "sqm
          Lift: " . $_POST['property_lift'] . "
          Payment upon arrival: " . $_POST['payment_upon_arrival'] . "
          How to get to the apartment by public transport): " . $_POST['how_to_get_there'] . "

          No. sleeps in total: " . $_POST['sleeps_total'] . "
          No. of bedrooms: " . $_POST['sleeps_bedrooms'] . "
          No. single beds: " . $_POST['sleeps_single_beds'] . "
          No. bunk beds: " . $_POST['sleeps_bunk_beds'] . "
          No. twin double beds: " . $_POST['sleeps_double_beds_twin'] . "
          No. queen double beds: " . $_POST['sleeps_double_beds_queen'] . "
          No. king double beds: " . $_POST['sleeps_double_beds_king'] . "
          No. single sofa beds: " . $_POST['sleeps_single_sofa'] . "
          No. double sofa beds: " . $_POST['sleeps_double_sofa'] . "
          Arrangement of beds and extra details of the bedrooms: " . $_POST['sleeps_arrangement_details'] . "
          Views from the bedroom windows: " . $_POST['sleeps_views_details'] . "
          Storage is in the bedrooms: " . $_POST['sleeps_storage_details'] . "
          Air conditioning in the bedrooms/sleeping area: " . $_POST['sleeps_airconditioning'] . "

          No. armchairs/lounge chairs: " . $_POST['living_area_chairs'] . "
          No. sofas: " . $_POST['living_area_sofas'] . "
          No. single sofa beds: " . $_POST['living_area_single_sofa_beds'] . "
          No. double sofa beds: " . $_POST['living_area_double_sofa_beds'] . "
          No. coffee tables: " . $_POST['living_area_coffee_tables'] . "
          No. side tables: " . $_POST['living_area_side_tables'] . "
          Dining table: " . $_POST['living_area_dining_table'] . "
          No. seats at dining table: " . $_POST['living_area_dining_table_seats'] . "
          Extra features and an impression of the living area: " . $_POST['living_area_details'] . "

          No. bathrooms: " . $_POST['bathroom_total'] . "
          No. bathrooms unsuited: " . $_POST['bathroom_unsuited'] . "
          No. toilet in bathroom: " . $_POST['bathroom_toilets'] . "
          No. separate WCs: " . $_POST['bathroom_toilets_separate'] . "
          No. bidet: " . $_POST['bathroom_bidets'] . "
          No. full bath with a shower: " . $_POST['bathroom_full_baths_w_shower'] . "
          No. full bath without a shower: " . $_POST['bathroom_full_baths_no_shower'] . "
          No. half bath with a shower: " . $_POST['bathroom_half_baths_w_shower'] . "
          No. walk_in shower: " . $_POST['bathroom_walk_in_showes'] . "
          Arrangement of bathrooms and any extra features: " . $_POST['batroom_details'] . "

          Kitchen:
          Kitchen type: " . $_POST['kitchen_type'] . "
          Size: " . $_POST['kitchen_size'] . "
          Breakfast bar: " . $_POST['kitchen_breakfast_bar'] . "
          Microwave: " . $_POST['kitchen_microwave'] . "
          Refrigerator: " . $_POST['kitchen_refrigerator'] . "
          Freezer: " . $_POST['kitchen_freezer'] . "
          Toaster: " . $_POST['kitchen_toaster'] . "
          Kettle: " . $_POST['kitchen_kettle'] . "
          Coffee maker: " . $_POST['kitchen_coffee_maker'] . "
          Espresso machine: " . $_POST['kitchen_espresso_machine'] . "
          Juicer: " . $_POST['kitchen_juicer'] . "
          Blender: " . $_POST['kitchen_blender'] . "
          Cooker: " . $_POST['kitchen_cooker'] . "
          Oven: " . $_POST['kitchen_oven'] . "
          Toaster: " . $_POST['kitchen_others'] . "
          Others: " . $_POST['kitchen_kettle'] . "

          Other rooms and useable living space: " . $_POST['other_rooms'] . "

          Smoking allowed: " . $_POST['info_smoking_allowed'] . "
          Pets allowed: " . $_POST['info_pets_allowed'] . "
          Children allowed: " . $_POST['info_children_allowed'] . "
          Baby cot available: " . $_POST['info_baby_cot'] . "
          High chair available: " . $_POST['info_high_chair'] . "
          Free parking available: " . $_POST['info_free_parking'] . "
          Paid parking on_site: " . $_POST['info_paid_parking_on_site'] . "
          Price of parking on_site: " . $_POST['info_price_parking_on_site'] . "
          Paid parking nearby: " . $_POST['info_paid_parking_nearby'] . "
          Price of parking nearby: " . $_POST['info_price_parking_nearby'] . "
          Swimming pool: " . $_POST['info_swimming_pool'] . "
          No. balconies: " . $_POST['info_balconies_total'] . "
          Total size of balconies: " . $_POST['info_balconies_size'] . "
          Balconie access: " . $_POST['info_balconies_access'] . "
          No. terraces: " . $_POST['info_terraces_total'] . "
          Total size of terraces: " . $_POST['info_terraces_size'] . "
          Terrace access: " . $_POST['info_terraces_access'] . "
          Space to sit on the balcony?: " . $_POST['info_balconies_space_to_sit'] . "
          Terrace/balcony furnished?: " . $_POST['info_terraces_furnished'] . "
          Sunshine on the terrace/balcony?: " . $_POST['info_terrace_sunshine'] . "
          Terrace/balcony on the same floor: " . $_POST['info_terrace_same_floor'] . "
          Terrace/balcony furnishment: " . $_POST['info_terraces_furnishment_details'] . "
          Views from the terrace/balcony: " . $_POST['info_terrace_views'] . "
          Where the terrace/balcony is accessed: " . $_POST['info_terrace_access_details'] . "
          Supermarket: " . $_POST['area_supermarket'] . "
          Restaurants: " . $_POST['area_restaurants'] . "
          Pharmacy: " . $_POST['area_pharmacy'] . "
          Bar: " . $_POST['area_bar'] . "
          Bakery: " . $_POST['area_bakery'] . "
          Shops: " . $_POST['area_shops'] . "
          Features of the building, street and surroundings: " . $_POST['area_detail'] . "

          Intercom: " . $_POST['equipment_intercom'] . "
          Video intercom: " . $_POST['equipment_video_intercom'] . "
          Double glazing: " . $_POST['equipment_double_glazing'] . "
          Washing machine: " . $_POST['equipment_washing_machine'] . "
          Dishwasher: " . $_POST['equipment_dishwasher'] . "
          Clothes dryer: " . $_POST['equipment_clothes_dryer'] . "
          Hairdryer: " . $_POST['equipment_hairdryer'] . "
          Ironing equipment: " . $_POST['equipment_ironing'] . "
          Hot air conditioning: " . $_POST['equipment_hot_airco'] . "
          Central heating: " . $_POST['equipment_central_heating'] . "
          Cold air conditioning: " . $_POST['equipment_cold_airco'] . "
          Central floor heating: " . $_POST['equipment_central_floor_heating'] . "
          Ceiling fan/cool air fan: " . $_POST['equipment_fan'] . "
          Electric heater: " . $_POST['equipment_electric_heater'] . "
          TV: " . $_POST['equipment_tv'] . "
          DVD?: " . $_POST['equipment_dvd'] . "
          CD?: " . $_POST['equipment_cd'] . "
          Music collection?: " . $_POST['equipment_music_collection'] . "
          Book collection: " . $_POST['equipment_book_collection'] . "
          Film collection: " . $_POST['equipment_film_collection'] . "
          Radio: " . $_POST['equipment_radio'] . "
          Internet available: " . $_POST['equipment_internet'] . "
          LAN: " . $_POST['equipment_lan'] . "
          Computer available: " . $_POST['equipment_computer'] . "
          WiFi: " . $_POST['equipment_wifi'] . "
          Phone with free calls: " . $_POST['equipment_phone_w_free_calls'] . "

          Other equipment: " . $_POST['equipment_other'] . "
          Strong points of a property: " . $_POST['remarks_strong_points'] . "
          Weak points of a property: " . $_POST['remarks_weak_points'] . "
          Other remarks: " . $_POST['remarks_other'] . "

          ");

          include("confirm.html");

          ?>
          [/CODE]

          right now it's set to go to confirm page and there you have a link that says "add more properties" and has a classic js back button code. but you can see that on the last page i put the same link, i need to be on the same page where is a submit button, so that when they click that it will submit the form and go back to first page with all the last values there. (well, because the whole form is on one page, it should colapse the first div and hide the others, basicly)

          thank you very much for helping with this :)

           
          • TNTEverett

            TNTEverett - 2008-04-19

            OK, so I think the issue is not in the processor.php file, it is in the form file.
            Lets get this fixed first and maybe this will be all you need. 

            This is the bottom of your index_v1.html file:

                  <tr>
                    <td class="spacer">&nbsp;</td>
                  </tr>
                  <tr>
                    <td colspan="2"></td>
                    <td colspan="2" align="right"><input id="saveForm" class="mainForm" type="submit" value="Submit" />
                    <a href="javascript:if (validatePage3()) { collapseElem('mainForm_3'); expandElem('mainForm_1');document.mainForm.submit();}"><span class="hwine"><u>submit and  go to add new property</u></span></a></td>
                  </tr>
                </table>
              </div>
              <div class=mainForm id="mainForm_4">
              Thank you
              </div>
            </form></div>
            </body>
            </html>

            The problem starts on the 6th line of what you see.  Make sure you only change the lines I show you (lines 6 and 7 of the above). 

            <td colspan="1" align="right"><input id="saveForm" class="mainForm" type="submit" value="Submit" /><a href="javascript:document.mainForm.submit();}"></td>
            <td colspan="1" align="right"><a href="javascript:if (validatePage3()) { collapseElem('mainForm_3'); expandElem('mainForm_1');}"><span class="hwine"><u>submit and  go to add new property</u></span></a></td>

            All this fix does is separate the submit function from the function that returns to continue editing the form pages.  I have seen the when returning to edit that all values are still populated. 
            Tell me, is this just how you received your zip file, or did you modify the last javascript function?  I would like to forward this issue to the developers if it is how you received your form. 

             
            • elearngroup

              elearngroup - 2008-04-19

              i done this change, but all it does it's going back, values are there but nothing is submitted???

              I need this button to do the double function - to submit and to go back.

              and why this link is just left like this: <a href="javascript:document.mainForm.submit();}"></td> ??? this link doesn't have a closed tag </a>

              and the sample that i did on the generator was much more simple, i just used it to get the template for the big one.

              so what do you think is this possible?

              and if i can suggest maybe processor.php should have something like email headers, where it can be put the sender of the email, because right now it shows the server.

               
              • TNTEverett

                TNTEverett - 2008-04-20

                I'm not sure why you would want to submit and then go back.  This doesn't seem verys usefull.  If you submit a record gets generated and sends you an email with the submission.  If you then go back and resubmit you get a second record and a second email sent.  Why would you want to allow multiple submissions this way? 
                The way I have left it is that you can go back to the begining to see if there is anything you want to change before you submit.  At the end when you are satisfied that everything is accurate you can click the submit button.  This seems reasonable and more like most large forms I have used in the past (make sure everything is accurate before you submit). 

                I agree that the terminating </a> should be used. 
                You could make the submit button provide a summary page that could be saved or printed by the user but I don't think you want a submit/restart combined function (possible but not practical nor do I recommend it). 

                As for the processor.php file it is meant to be a simple starting point.  Headers can be used but customization beyond the simple form is left to the user. 

                 
                • elearngroup

                  elearngroup - 2008-04-20

                  this si why:

                  we have a owner who is having 12 apartments, he needs to put the input in every field of this form and send it to us. if the form is clean every time after submittion then he needs to do it all over again - 130 fields!!!, now imagene doing that 12 times!!!??

                  so what i want is that after submittion he got back to the form with last submitted values ther so he will only have few fields to change (address, his info, furnishing, equipment is 95% the same in this apartments, oply diference is  size, no. of bedrooms...)

                  i know that refresh is a security to prevent double post, but i need to make this frm easier for them, bottom line is that we cannot do it without them.

                  so is this possile?

                   
                  • TNTEverett

                    TNTEverett - 2008-04-20

                    Why would you not save the data in some sort of db then? 
                    Text file, csv file, sql db, or some other sort of db. 
                    The db could easily be edited to add, delete, copy or change the data. 

                    Or why wouldn't this person send you an Excel spreadshhet with all the data instead of using this form? 

                    What you are looking for can be done, I'm just not sure why it is nesessary. 

                     
    • elearngroup

      elearngroup - 2008-04-18

      oh, that is great, i need to go home now, i am at work, but in 2h i will sned you. thank you

       
    • TNTEverett

      TNTEverett - 2008-04-20

      If you want to implement what you are asking for leave everything as is so far and modify the confirm.html file. 

      Add this back button to the end of the confirm page. 

              <BR/><ul class=mainForm><li class=mainForm><label class=formFieldQuestion>Thank you.</label></li></ul>

      <INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;">

              <BR/></div><div id="footer"><p class="footer"><a class=footer href=http://phpformgen.sourceforge.net>Generated by phpFormGenerator</a></p></div>
          </body>
          </html>

      This way the confirmation email is sent and the user has the opportunity to go back with all previous values still set. 

       
    • Musawir Ali

      Musawir Ali - 2008-04-23

      if you want to retain the previous entries, use the pre 3.0 version of the program to create your form. It retains previous entries... but as a side effect ... it really shouldn't need to keep them once the form data has been submitted. In fact, its probably a security issue (consider a public computer, a user can keep pressing the back button and see the personal info filled out by the previous user). If you are relying on this "feature", then you are basically relying on indeterministic browser behavior rather than a proper method of data entry. v3.0 will not let you do this, simply because the back button is meaningless. The different "pages" of the form are in fact all on the same page, they are just hidden. When you proceed with the form entry, the program simply hides and "unhides" the different pages. But as far as your web browser is concerned, you are still on one page, and therefore your back button will not work.

      Lastly, in my opinion it is better if all the fields are entered each time since this prevents data entry errors. But if you must have this because the redundancy is wasting a lot of time, you should get the proper logic programmed in. A simple solution would be to edit the HTML and give each of the form fields a default value. This really doesn't require any programming knowledge, and it looks like this really what you need.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.