473,471 Members | 2,040 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Buttons to two different pages in the same form

2 New Member
Hi there,

I want to create a form with two buttons on that navigate to two different pages. The code I have at the moment looks like this:

<form action="login.php" method="post">
<table rows=2>
<tr>
<td><h5>Username</h5></td>
<td><input type="text" name="UID"/></td>
</tr>
<tr>
<td><h5>Password</h5></td>
<td><input type="password" name="PWD"/></td>
</tr>
<table>
<input type="submit" name="submit_Login" value="Login"/> or <input type="submit" name="submit_register" value="Register"/>
</form>

What I really need is a different form action for each button. Any idea how to achieve this? Thanks,

Mark Roworth
Sep 17 '06 #1
1 2379
ronverdonk
4,258 Recognized Expert Specialist
The form action will be executed for both buttons. However, you can capture which button is pressed by using the following code at the start of your login.php script. Depending on which key is pressed, you can take either Login or Register action. In this sample I echo which key was pressed.
[PHP]<?php
if ($_POST['submit_Login'] == 'Login') {
echo 'You pressed LOGIN';
// do your login processing
}
else if ($_POST['submit_register'] == 'Register') {
echo 'You pressed REGISTER';
// do your register processing
}
// otherwise it will display the form again
?>
<form action="login.php" method="post">
<table rows=2>
<tr>
<td><h5>Username</h5></td>
<td><input type="text" name="UID"/></td>
</tr>
<tr>
<td><h5>Password</h5></td>
<td><input type="password" name="PWD"/></td>
</tr>
<table>
<input type="submit" name="submit_Login" value="Login"/>
<input type="submit" name="submit_register" value="Register"/>
</form>[/PHP]

Ronald :cool:
Sep 17 '06 #2

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

Similar topics

8
by: Ralph Freshour | last post by:
Is it possible to inhibit the browser Back/Fwd buttons via PHP? Thanks...
1
by: KS | last post by:
I write my html pages as .jsp files (java server pages). The final result when the page is rendered in the browser, and I do a view source, is nothing less the normal HTML codes. The problem is I...
3
by: YT | last post by:
Greetings, Just wondering if someone out there can help with this issue. I have a questionnaire that i'm building. Each step is a separate web page with a form and a next button & back button,...
17
by: Klaus Schulz | last post by:
Hello, for a project I am currently working at, I have to use form-buttons and normal links (a href...) in the same pages together. Both should look the same. No problem with IE and Opera but I...
4
by: Penny | last post by:
Hi all, I have a checkout page in my online shopping cart that needs two submit buttons that direct to two seperate pages. Whichever button the user clicks, the destination page will use much...
5
by: Lyn | last post by:
Hi, I hope someone can help. I have a main form which mostly fills the Access window. In the bottom half of this form I have a tab control to display various types of data related to the main...
5
by: Axel | last post by:
An Access 2000 question Hi is is possible to have (as a subform) a continous form with 0..n buttons which have different images in each row. (Personally I would have preferred a button...
2
by: Kevin Audleman | last post by:
Hi, is it possible to create a form that has two submit buttons, and each one submits to a different page? Thanks, Kevin
4
by: Husain | last post by:
Hello. I am new to Javascript and JSP. I would like to have multiple submit buttons in a form. Each button has a different action? How can I go about doing that? How can I obtain the button's...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.