Redirect a Page after a Button Click

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rambaldi
    New Member
    • Mar 2007
    • 42

    Redirect a Page after a Button Click

    Hi people, i'm new to php...

    How can i redirect a page after a button click??? This might be very trivial but i really need help with this...

    I'm not very good at english so if you didnt understand, just alert me and i'll try to express better.


    Thanks in Advance
  • epots9
    Recognized Expert Top Contributor
    • May 2007
    • 1352

    #2
    u would modify the header:
    [PHP]header("Locatio n: http://google.ca");[/PHP]

    of course u would put that in some kind of if statement or something cuz u wouldn't want it to redirect everytime it gets to that line in the php file (well sometimes u do).

    good luck

    Comment

    • kovik
      Recognized Expert Top Contributor
      • Jun 2007
      • 1044

      #3
      header() wouldn't work at all in this situation, really. To click on a button, headers would have already been sent with the output.

      Why do you need this on a button? Is this a form?

      Comment

      • Rambaldi
        New Member
        • Mar 2007
        • 42

        #4
        the want the button to open another php file...

        Example: one of the them is a Categorie button. My objective is when i click it, it open a php file that has all the categories that the client can choose.

        As i been seeing, i could use a form if i would got info to pass for the another page, but i just wanna open another page without passing any values...

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #5
          Heya, Rambaldi.

          Probably the easiest way to do what you're describing is to open a pop-up using window.open() on the JavaScript side.

          Comment

          • kovik
            Recognized Expert Top Contributor
            • Jun 2007
            • 1044

            #6
            I would avoid the use of JavaScript for this, as if JavaScript is disabled, it'd render the page useless.

            The *smart* solution would be to ditch buttons and use links since that is what you are using them for. You can style links to look like buttons, but actual buttons are not what you want to use.

            If you insist on using buttons, you can attach them to a form that posts to the next page.

            [code=html]<form action="page.ph p"><input type="submit" value="Next Page" /></form>[/code]

            Comment

            • dafodil
              Contributor
              • Jul 2007
              • 389

              #7
              Originally posted by volectricity
              I would avoid the use of JavaScript for this, as if JavaScript is disabled, it'd render the page useless.

              The *smart* solution would be to ditch buttons and use links since that is what you are using them for. You can style links to look like buttons, but actual buttons are not what you want to use.

              If you insist on using buttons, you can attach them to a form that posts to the next page.

              [code=html]<form action="page.ph p"><input type="submit" value="Next Page" /></form>[/code]
              I don't agree with using a submit button because he's not passing any values....

              Try using javascript instead....

              Most browsers support javascript already....

              Try what pbmods said...

              Comment

              • Rambaldi
                New Member
                • Mar 2007
                • 42

                #8
                i use the Window.open() comand, and it helps =) Thanks for the help guys

                Comment

                • pbmods
                  Recognized Expert Expert
                  • Apr 2007
                  • 5821

                  #9
                  Heya, Rambaldi.

                  Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)

                  Comment

                  • Rhishabh07
                    New Member
                    • Jul 2007
                    • 21

                    #10
                    header("locatio n:pagename.php" );

                    pagename.php means where to redirect.use this on that page from where u wan to go on pagename.php

                    Comment

                    Working...