Announcement

Collapse
No announcement yet.

Form Links?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Form Links?

    Hi...
    I was wondering if it is possible to use a form so that a user can select a City and a Shop (in a combobox) and then get directed to a specific page by clicking the sumbit button.

    If you want to see where I am stuck please have a look at this page : http://www.naturaltherapynetwork.net/test.html If you select any of the options and then click submit - it re-directs you to the Home(Index) Page... but the browser address has all the info that you submitted. For the form I set the action to http://www.naturaltherapynetwork.net - I think this is where the problem is. Is there some way to fix this??? Please help me... oh, and I can't code PHP or JavaScript or HTML...

    Thanks....
    Chris

  • #2
    Re: Form Links?

    Then why have a form? Simply use a menu bar. Lets say you did have that option on a form- once they clicked it- they would be taken off the form and sent to that page.

    Not quite sure what you want to accomplish. Maybe give us an example of exactly what you are trying to do.

    Andy
    PHP- is a blast!

    Comment


    • #3
      Re: Form Links?

      Hi,

      Thanks for your reply...

      This is what I want... If the user selects "Bedford" and then selects "Medicine Shop" I want the user to be directed to www.naturaltherapynetwork.net/bedford/mshop.html - So that the user can see all the "MedicineShops" in "Bedford"...

      I see what you are saying that the user could select "Beford" and then be directed to www.naturaltherpaynetwork.net/bedford.html and then the user could select a shop from that page and be directed to www.naturaltherapynetwork.net/bedford/mshop.html - but i was hoping to skip that. Is it possible to do that with a form or anything else?

      Thank you again,
      Chris

      Comment


      • #4
        Re: Form Links?

        Yes it is possible. You would use if statements to determine what re-direct is used. It will be a very long (and fairly complicated) script. It would be far easier to create a webpage with the "Areas" and "Shoppes" listed with appropriate links. However- this has intrigued me as to the mechanism that would make it work. I will have a look at it tonight and if I am able to get it to work- I will post back.

        Cheers-

        Andy
        PHP- is a blast!

        Comment


        • #5
          Re: Form Links?

          Thank you very much Andy, I really appreciate it.

          Chris

          Comment


          • #6
            Re: Form Links?

            I got called into work today- I will have something for you tonight. I have a little more testing but so far so good.

            Andy
            PHP- is a blast!

            Comment


            • #7
              Re: Form Links?

              Wow... thanks a million. It would really help me improve my website.

              Chris

              Comment


              • #8
                Re: Form Links?

                Chris-
                You have mail.

                Just to explain a little- In the combo box, each Item will be given an Item Name. Each will be assigned a numeric value.
                The php script will then evaluate the City field "+" the Shop field and that sum will determine which link is executed.
                So if Bedford = 10 and Health Shops = 100 then the sum of these would equal 110 and that would be the link to the
                Bedford Health Shops page. See script below as an example;
                <?php
                $city= $HTTP_POST_VARS['city'];
                $typeshop= $HTTP_POST_VARS['typeshop'];
                $total= ($city + $typeshop);
                //
                //$city is a combo box
                //$typeshop is a combo box
                //Each city item will be assigned a value like 10, 20, 30
                //and each typeshop item will be assigned a value of 100, 200, 300
                //then use the php to calculate the value and re-direct accordingly
                //
                switch ($total)
                {
                case 110:
                echo'<meta http-equiv= "refresh" content= "0; URL = http://www.yourwebsite.com/shop_page1.html"/>';
                break;
                case 210:
                echo'<meta http-equiv= "refresh" content= "0; URL = http://www.yourwebsite.com/shop_page2.html"/>';
                break;
                case 310:
                echo'<meta http-equiv= "refresh" content= "0; URL = http://www.yourwebsite.com/shop_page3.html"/>';
                break;
                case 120:
                echo'<meta http-equiv= "refresh" content= "0; URL = http://www.yourwebsite.com/shop_page4.html"/>';
                break;
                case 220:
                echo'<meta http-equiv= "refresh" content= "0; URL = http://www.yourwebsite.com/shop_page5.html"/>';
                break;
                case 320:
                echo'<meta http-equiv= "refresh" content= "0; URL = http://www.yourwebsite.com/shop_page6.html"/>';
                // This would continue for each shop page
                }
                ?>
                Thats pretty much it.

                Andy
                PHP- is a blast!

                Comment


                • #9
                  Re: Form Links?

                  Thanks Andy,

                  I'll go and give it a test now... This should really help!!!

                  Best Regards,
                  Chris

                  Comment


                  • #10
                    Re: Form Links?

                    Excuse me for cutting in. If we suppose there are 10 cities with 5 diffrent shops each, that would become a very long script. It should also be edited each time a new city or new shop is being added.

                    I have seen in c.mclean's initial post, that he would like to have each area(each city) in a folder, and the relevant shop pages in that folder. In that case, the values of the Listboxes can be directly used to create the link, with a script like this:

                    <?php
                    $nearcity= $HTTP_POST_VARS['nearcity'];
                    $shop= $HTTP_POST_VARS['shop'];
                    $link = "http://www.naturaltherapynetwork.net/$nearcity/$shop.html";
                    header("Location: $link");
                    ?>
                    The values of the "nearcity" listbox will provide the folder name, and the values of the "shop" Listbox will provide the page name.
                    The $link variable will be created according to the values submitted, and will redirect to the appropiate page.

                    It would be advisable to use only lowercase letters and no spaces in the listboxes values. Some browsers don't like uppercase letters.

                    This script will work with as many Cities and as many shops, without any change. The only necessary condition is that the relevant html pages exist.

                    It can also be modified for having all the pages in the same folder, but in that case the page names mustbe like this: "dunstableashop"

                    and the 3rd line of the script should become:

                    $link = "http://www.naturaltherapynetwork.net/$nearcity.$shop.html";

                    Please note that there is a "weak" point in the script: if there are f.e. 5 different kinds of shops, but, in one city, we only have, let's say only 4 shops, the script will create a non valid link for the 5th shop. So, it is necessary to create a page for all the shop categories: if a shop doen't exist in one town, the page MUST be there, even only to inform the visitor that this shop is not available for that town.
                    You can also make the selection directly in the form page, without any php, using this javascript:

                    http://www.dynamicdrive.com/dynamici...menu/index.htm


                    However, this one also needs manual updating each time you add something.
                    Navaldesign
                    Logger Lite: Low Cost, Customizable, multifeatured Login script
                    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                    Comment


                    • #11
                      Re: Form Links?

                      Wow...

                      Thanks Naval... that help is going to cut the work I have to do in half. Thank you both for your excellent advice. I am going to try to add it to my website today.

                      If I have any problems I'll post them on this thread.

                      Thanks,
                      Chris

                      Comment


                      • #12
                        Re: Form Links?

                        Nice one Naval! One to put in my FYI folder.

                        Andy
                        PHP- is a blast!

                        Comment


                        • #13
                          Re: Form Links?

                          Hi Naval...

                          I have a problem... when I go to http://www.naturaltherapynetwork.net/test.html and go through the process - after I have installed your code - I get an error. I have changed your code a little - to add another combobox. I have no idea why I am getting this error. It keeps on wanted to re-direct me to http://www.naturaltherapynetwork.net...herapy///.html

                          Could you please have a look at the the test page and see if you can find the problem? The changed code is there as well.

                          The page I want it to get directed to is http://www.naturaltherapynetwork.net...bed/about.html

                          Thank you,
                          Chris

                          Comment


                          • #14
                            Re: Form Links?

                            Ok... I found the problem...

                            I had the form set to GET when it should be set to POST.... my bad.

                            Thank you so much for all your help,
                            Chris

                            Comment


                            • #15
                              Re: Form Links?

                              Sorry but i don't understand. As soon as i submit, it DOES redirect me t to the http://www.naturaltherapynetwork.net...bed/about.html

                              Isn't that that you wanted ?
                              Navaldesign
                              Logger Lite: Low Cost, Customizable, multifeatured Login script
                              Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                              DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                              Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                              Comment

                              Working...
                              X