473,378 Members | 1,409 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,378 software developers and data experts.

posting variables from forms

With a form, I have two buttons.

One of them says:
- pay here

The other says
- pay somewhere else

Now, can I change the location to which the variables from the Form are
posted, depending on the button that they click? or am I always restricted
to the location specified in the action (e.g. <form method="post"
action="mynewpage.php">)

TIA

- Nicolaas
Jan 19 '06 #1
8 1415
windandwaves wrote:
With a form, I have two buttons.

One of them says:
- pay here

The other says
- pay somewhere else

Now, can I change the location to which the variables from the Form are
posted, depending on the button that they click? or am I always restricted
to the location specified in the action (e.g. <form method="post"
action="mynewpage.php">)

Not without a little bit of JavaScript on the page to implement an
onclick handler for the button.

--
Ian Collins.
Jan 19 '06 #2
Message-ID: <11***************@drone2-svc-skyt.qsi.net.nz> from Ian
Collins contained the following:
Now, can I change the location to which the variables from the Form are
posted, depending on the button that they click? or am I always restricted
to the location specified in the action (e.g. <form method="post"
action="mynewpage.php">)

Not without a little bit of JavaScript on the page to implement an
onclick handler for the button.


Yuck!

Why not put both methods in mynewpage.php and choose which one to use
depending on which button is pressed?

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jan 19 '06 #3
Al
> Why not put both methods in mynewpage.php and choose which one to use
depending on which button is pressed?


Somewhere else might be a different site.

Having said that, if "somewhere else" can take GETs rather than POSTs,
you can direct all form traffic to one php file and see which submit
button name/value pair is activated and then either run the script if
it's "here" or do a header("Location: ") if it's the "somewhere else"
one... But that IS a little odd, and the javascript method is a little
smoother.

Jan 20 '06 #4
Al wrote:
Why not put both methods in mynewpage.php and choose which one to use
depending on which button is pressed?


Somewhere else might be a different site.

Having said that, if "somewhere else" can take GETs rather than POSTs,
you can direct all form traffic to one php file and see which submit
button name/value pair is activated and then either run the script if
it's "here" or do a header("Location: ") if it's the "somewhere else"
one... But that IS a little odd, and the javascript method is a little
smoother.


Yes, it is funny. Because it seems to make sense that depending on the
choices from the user the data may have to go to site A or site B. Doing
the header function means that you loose the posted variables as posts so
that you have to post them again. Can you do something like this:
header(post-type, $_POST), basically directly reposting all posted variables
to a new location?

HTMS (hope that makes sense)

- Nicolaas
Jan 20 '06 #5
Al

windandwaves wrote:
Doing
the header function means that you loose the posted variables as posts so
that you have to post them again. Can you do something like this:
header(post-type, $_POST), basically directly reposting all posted variables
to a new location?


Well yes, it loses the informaiton as POSTs but you can recreate them
as GETs and send them on their way in a header("Location: ");

But if you want to resend as POSTs I think it's mildly impossible. I'm
pretty sure you can't do it your way. The header() command just adds
stuff the to header being sent back to the user, rather than the header
of the redirected request, unfortunately :)

I think the javascript way seems to be your only chance, and it's not
particularly invasive. Plus if people have javascript disabled then you
can default to my POST -> GET code and at least TRY to fulfil the silly
non-javascript-user's request :)

So yeah, employ both methods?

Jan 20 '06 #6
windandwaves wrote:
Can you do something like this:
header(post-type, $_POST), basically directly reposting all posted variables
to a new location?


Have a look at cURL <http://www.php.net/curl>.

--
If you're posting through Google read <http://cfaj.freeshell.org/google>
Jan 21 '06 #7
some people don't have JavaScript - some Accessible machines for the
disabled, for instance.
I found this out when reading a book on making sites accessible.

"Al" <al************@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...

windandwaves wrote:
Doing
the header function means that you loose the posted variables as posts so
that you have to post them again. Can you do something like this:
header(post-type, $_POST), basically directly reposting all posted
variables
to a new location?


Well yes, it loses the informaiton as POSTs but you can recreate them
as GETs and send them on their way in a header("Location: ");

But if you want to resend as POSTs I think it's mildly impossible. I'm
pretty sure you can't do it your way. The header() command just adds
stuff the to header being sent back to the user, rather than the header
of the redirected request, unfortunately :)

I think the javascript way seems to be your only chance, and it's not
particularly invasive. Plus if people have javascript disabled then you
can default to my POST -> GET code and at least TRY to fulfil the silly
non-javascript-user's request :)

So yeah, employ both methods?

Jan 23 '06 #8
Al
Jim Michaels wrote:
some people don't have JavaScript - some Accessible machines for the
disabled, for instance.


Well yes, my smiley was to show I was only joking. But if you saw, I
did say that both methods should be employed and that the default
behaviour should be the nicer-working JavaScript one.

Jan 25 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Larry L | last post by:
I have a Module that declares several arrays as public, some string, some integers. I then have 2 forms. Form A is the main form, that loads on start-up, and has a command button to open Form B. On...
5
by: Ross A. Finlayson | last post by:
Hi, I'm scratching together an Access database. The development box is Office 95, the deployment box Office 2003. So anyways I am griping about forms and global variables. Say for example...
17
by: MLH | last post by:
A97 Topic: If there is a way to preserve the values assigned to global variables when an untrapped runtime error occurs? I don't think there is, but I thought I'd ask. During development, I'm...
3
by: Jessica Loriena | last post by:
I'm trying to write a simple "register form / validate and store in database / show welcome screen" application with ASP.Net. With conventional ASP, I used Session variables and it went something...
7
by: Jeff Casbeer | last post by:
New to VB.. What is the VB syntax for posting a Windows event? For example, to have an event fire AFTER a form loads, I'd add a posted call to a "post_load" event, from "load". What is the VB...
2
by: dumbo | last post by:
Hello, who gives one more shining solution to me? My application load form "A". The form "A" by means of a push-button load form "B" that in its turn by means of a push-button load form "C". Form...
27
by: thomasp | last post by:
Variables that I would like to make available to all forms and modules in my program, where should I declare them? At the momment I just created a module and have them all declared public there. ...
8
by: Leszek | last post by:
Hi. I have two forms each in different file user need to fill both one after another. Is it possible to display variables from both forms at the end? does $_POST contains variables from...
2
by: deshg | last post by:
Hey everyone, I am a php programmer originally and am just helping a friend of mine update their website that they paid a designer (well that's what he called himself!) to do ages ago. I have...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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...
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...

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.