473,387 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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
Jul 5 '07 #1
9 18134
epots9
1,351 Expert 1GB
u would modify the header:
[PHP]header("Location: 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
Jul 5 '07 #2
kovik
1,044 Expert 1GB
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?
Jul 5 '07 #3
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...
Jul 5 '07 #4
pbmods
5,821 Expert 4TB
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.
Jul 5 '07 #5
kovik
1,044 Expert 1GB
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.

Expand|Select|Wrap|Line Numbers
  1. <form action="page.php"><input type="submit" value="Next Page" /></form>
Jul 5 '07 #6
dafodil
392 256MB
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.

Expand|Select|Wrap|Line Numbers
  1. <form action="page.php"><input type="submit" value="Next Page" /></form>
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...
Jul 6 '07 #7
i use the Window.open() comand, and it helps =) Thanks for the help guys
Jul 7 '07 #8
pbmods
5,821 Expert 4TB
Heya, Rambaldi.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Jul 7 '07 #9
header("location:pagename.php");

pagename.php means where to redirect.use this on that page from where u wan to go on pagename.php
Jul 11 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Mark Lingen | last post by:
I've found a problem with postback event handling and webcontrol buttons. Try out the following code in an ASP.Net project and you will see. Create a web project in VB.Net and drop this code...
2
by: ACaunter | last post by:
Hi there, I started a new website in asp.net.. made a page with some buttons and that on it.. copied it several times on different pages, so i get the save buttons in the same position on each...
7
by: xzzy | last post by:
I have several pages in a frame and need the code behind of a page in one of the frames to cause a button in that page to click so the javascript in that button will execute on the client...
3
by: smHaig | last post by:
Not being an web programmer I am unable to figure out how to put the hyperlink mailto:emailaddress in a button click event. I do not want a hyperlink on the form. I have found nothing to address...
1
by: R.A.M. | last post by:
Hello, I have very simple problem which I present here second time, because I haven't got a solution. I need to process asp:Button click at server. I have written (my experience is little) in...
1
by: Aussie Rules | last post by:
Hi, I have an image button on my page, and I want to have a popup window open up when the user clicks the imagebutton, and if possible set the window configuration(ie no tool bar, etc) like...
1
by: shapper | last post by:
Hello, I am creating a custom control where I have a button. Somehow my button click event is not being raised. I tried to place different codes inside MyButton_Click and nothing runs. Then I...
1
by: thirunavukarasukm | last post by:
i created one web form the form contain two label box and text box in the form one button is placed i click the button the page redirect to next page window.location.href="fdfgd.com";
2
by: hellboss | last post by:
HI ! I am workin wit asp.net vs 05 , I have some document file in my local directory and its corresponding path and its file name is strored in a the database table. In the Page 1, i have listed...
2
by: Max2006 | last post by:
Hi, I have a simple form with a button on it. After a button click postback, anytime user press F5 (browser page refresh), the button's OnClick event handler is called again without the button...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.