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

Passing HTTP POST information to another script - How?

Hi there,

I have a situation where I want to have multiple submit buttons on the same
form and therefore want to use a redirection php script that checks the
value associated with the submit form variable to calculate which submit was
pressed and then redirects the user to another php page accordingly.

I used:
headers ("location:myphpscript.php")

to do this.

However automatically this does not pass on the information sent in the form
POST. I did start looking into reencoding the $_REQUEST into a GET string to
append to the URL, but this is a bit crude because the original form submit
uses a post and had a lot of information (some of which is also held in
$_FILES).

So is there a better way to go about this? How can I simulate a POST?

My second related question on this subject (I was going to post this
separately but it's probably better here) is whether there is a limit to the
amount of information that can be passed via an HTTP GET.
I once remember reading there is a 255 character limit to a URL address and
if this also includes the variable information after the ? this is quite
restrictive.

Kind regards

Dave
Jul 17 '05 #1
10 3235
"Dave Smithz" <SPAM FREE WORLD> wrote:
Hi there,

I have a situation where I want to have multiple submit buttons on the
same form and therefore want to use a redirection php script that checks
the value associated with the submit form variable to calculate which
submit was pressed and then redirects the user to another php page
accordingly.

I used:
headers ("location:myphpscript.php")

to do this.

However automatically this does not pass on the information sent in the
form POST. I did start looking into reencoding the $_REQUEST into a GET
string to append to the URL, but this is a bit crude because the original
form submit uses a post and had a lot of information (some of which is
also held in $_FILES).

So is there a better way to go about this? How can I simulate a POST?

My second related question on this subject (I was going to post this
separately but it's probably better here) is whether there is a limit to
the
amount of information that can be passed via an HTTP GET.
I once remember reading there is a 255 character limit to a URL address
and if this also includes the variable information after the ? this is
quite restrictive.

Kind regards

Dave


Hi Dave,

When php.net fixed their bug, look here:
http://nl2.php.net/manual/en/ref.curl.php

curl lets you mimic postings.

Regards,
Erwin Moller
Jul 17 '05 #2
"Dave Smithz" <SPAM FREE WORLD> wrote:
Hi there,

I have a situation where I want to have multiple submit buttons on the
same form and therefore want to use a redirection php script that checks
the value associated with the submit form variable to calculate which
submit was pressed and then redirects the user to another php page
accordingly.

I used:
headers ("location:myphpscript.php")

<snip>
Change the action of the form from javascript?

....or...

use a mini front controller which includes the relevant script?

Need more?

C.
Jul 17 '05 #3

"Colin McKinnon" <co**************@andthis.mms3.com> wrote in message
news:cv5106$o7i$1> > Hi there,
<snip>
Change the action of the form from javascript?


Forgot to say I can't use Javascript - cannot risk users not having it on.
...or...

use a mini front controller which includes the relevant script?


What is this? Does it require JavaScript?

Cheers

Dave
Jul 17 '05 #4
Dave Smithz wrote:
Hi there,

I have a situation where I want to have multiple submit buttons on the same
form and therefore want to use a redirection php script that checks the
value associated with the submit form variable to calculate which submit was
pressed and then redirects the user to another php page accordingly.
Why can't you just combine your PHP scripts (either in a single file or with
"require" statements)?
I used:
headers ("location:myphpscript.php")

to do this.
By redirecting POST requests you are asking for trouble. For example, take a
look at <http://ppewww.ph.gla.ac.uk/~flavell/www/post-redirect.html>. A
simple header statement just won't work properly, even if you get the syntax
right and use an absolute URI like you're supposed to.
However automatically this does not pass on the information sent in the form
POST. I did start looking into reencoding the $_REQUEST into a GET string to
append to the URL, but this is a bit crude because the original form submit
uses a post and had a lot of information (some of which is also held in
$_FILES).
By redirecting a POST request you're asking the client's browser to re-issue
the request to a different URL. That would mean sending the file twice. I
don't think that's a good idea. :-/
So is there a better way to go about this? How can I simulate a POST?
Do all your server-side processing at the URL specified by the form's action
attribute. That's the way things are supposed to work. Or use different
forms linked to different server-side scripts.

Could you perhaps explain a bit more about what you're trying to do with
this form?
My second related question on this subject (I was going to post this
separately but it's probably better here) is whether there is a limit to the
amount of information that can be passed via an HTTP GET.
I once remember reading there is a 255 character limit to a URL address and
if this also includes the variable information after the ? this is quite
restrictive.


I think it' more like 4096 characters, but don't take my word for it. It's
definitely a lot more than 255.

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
Jul 17 '05 #5
Dave Smithz wrote:
My second related question on this subject (I was going to post this
separately but it's probably better here) is whether there is a limit to the
amount of information that can be passed via an HTTP GET.
Depends.

In theory, no. The generic URI spec does not impose a limit
on the length of URIs, and the HTTP spec does not impose a
limit on the length of its URIs either. From sec. 3.2.1 of
the latter:

| The HTTP protocol does not place any /a priori/ limit on
| the length of a URI. Servers MUST be able to handle the
| URI of any resource they serve, and SHOULD be able to
| handle URIs of unbounded length if they provide GET-based
| forms that could generate such URIs. A server SHOULD
| return 414 (Request-URI Too Long) status if a URI is
| longer than the server can handle ...

http://www.ietf.org/rfc/rfc2616.txt

So an HTTP URI with a query string ten thousand characters
long, if unwieldy, accords with the interworking
specifications.

In practice, however, yes. There are implementation-
specific limits.
I once remember reading there is a 255 character limit to a URL address and
if this also includes the variable information after the ? this is quite
restrictive.


RFC2616 (1999) notes that older software might not support
URIs longer than 255 bytes. I should like to think that
that limit is imposed only by some archaic implementations,
the likes of which you'd seldom encounter nowadays.

Slainte!

--
Jock
Jul 17 '05 #6

"Dave Smithz" <SPAM FREE WORLD> wrote in message
news:42********@news1.homechoice.co.uk...
Hi there,

I have a situation where I want to have multiple submit buttons on the
same
form and therefore want to use a redirection php script that checks the
value associated with the submit form variable to calculate which submit
was
pressed and then redirects the user to another php page accordingly.

I used:
headers ("location:myphpscript.php") ...... So is there a better way to go about this? How can I simulate a POST?


You can put all kinds of data "in session".

eg,

in the script receiving the original POST:

session_start(); // should appear before *any* output in the script...
$_SESSION['posted'] = $_POST;

The above stores the entire post array in-session.
Now you can redirect to any page you want, or the user can click on a link
to a script of yours, and within that destination script you do:

session_start(); // should appear before *any* output in the script...
posted = $_SESSION['entryFormValues'];

Now the posted array is available and has the original $_POST info from the
original script.

(read up on sessions...extremely useful stuff)

-- Dan

Jul 17 '05 #7
"Dave Smithz" <SPAM FREE WORLD> wrote in message
news:42********@news1.homechoice.co.uk...
Hi there,

I have a situation where I want to have multiple submit buttons on the same form and therefore want to use a redirection php script that checks the
value associated with the submit form variable to calculate which submit was pressed and then redirects the user to another php page accordingly.

I used:
headers ("location:myphpscript.php")

to do this.
The HTTP status code 307 is used for redirecting a POST. Only works well
with IE though.
However automatically this does not pass on the information sent in the form POST. I did start looking into reencoding the $_REQUEST into a GET string to append to the URL, but this is a bit crude because the original form submit uses a post and had a lot of information (some of which is also held in
$_FILES).

So is there a better way to go about this? How can I simulate a POST?
If session is available, you can stick the $_POST array in there:

$key = md5(serialize($_POST));
$_SESSION[$key] = $_POST;
header("Location: otherfile.php?key=$key");

then retrieve it in the other page:
$_POST = $_SESSION[$_GET['key']];
My second related question on this subject (I was going to post this
separately but it's probably better here) is whether there is a limit to the amount of information that can be passed via an HTTP GET.
I once remember reading there is a 255 character limit to a URL address and if this also includes the variable information after the ? this is quite
restrictive.


It was a problem affecting one of the ancient browsers. Might have been IE
2, I can't remember. The browser would die from a stack overflow error when
the URL is longer than 255.
Jul 17 '05 #8
Oops! Correction:
You can put all kinds of data "in session".

eg,

in the script receiving the original POST:

session_start(); // should appear before *any* output in the script...
$_SESSION['posted'] = $_POST;

The above stores the entire post array in-session.
Now you can redirect to any page you want, or the user can click on a link
to a script of yours, and within that destination script you do:

session_start(); // should appear before *any* output in the script...
posted = $_SESSION['entryFormValues'];


Above line should be: posted = $_SESSION['posted'];

Sorry about that...
Jul 17 '05 #9
Chung Leong wrote:
The HTTP status code 307 is used for redirecting a POST. Only works well
with IE though.


Actually it doesn't work well with IE at all.
See <http://ppewww.ph.gla.ac.uk/~flavell/www/post-redirect.html>

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
Jul 17 '05 #10
Dave Smithz wrote:
Hi there,

I have a situation where I want to have multiple submit buttons on the same form and therefore want to use a redirection php script that checks the value associated with the submit form variable to calculate which submit was pressed and then redirects the user to another php page accordingly.

I used:
headers ("location:myphpscript.php")

to do this.

However automatically this does not pass on the information sent in the form POST. I did start looking into reencoding the $_REQUEST into a GET string to append to the URL, but this is a bit crude because the original form submit uses a post and had a lot of information (some of which is also held in $_FILES).

So is there a better way to go about this? How can I simulate a POST?


I don't know, why you have to redirect to another page. If you have
some good Form handler mechanism, you can do like this (in the same
page--even witout losing the clarity/readability/etc):

if ( $foo->isFormSubmitted($_POST, 'deposit') )
{
$foo->isValidDepositFields() and
$foo->addToDepositTable();
}
else if ( $foo->isFormSubmitted($_POST, 'withdraw') )
{
...
}

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #11

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

Similar topics

3
by: Ko Ko | last post by:
Dear All, I am wondering how to pass one variable from one php file to another continuously or discontinuously. For example, variable $a is declared in file1.php. I like to use that variable in...
1
by: Joe | last post by:
I am trying to write a Perlscript to be used with some HTML pages. Here is how it works: 1.. The first HTML page has a form which requests for user input. Then it passes the QUERY_STRING...
6
by: Robert Cohen | last post by:
Hi All, I have what is an easy question for you all, but I have not idea (this is in vbscript). I have this script below that works great. It figures out the user logged in and gives the AD...
4
by: Jason Us | last post by:
Does anyone have experience with passing variables from an ASP page to a JSP page. The way it currently works in passing the SSN in the URL. This cannot be good. I thought that storing a...
2
by: Richard | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** HI, I am working on a project where I need to input data to a (local) HTML page using multiple form elements, such as text,...
3
by: AndyDunning | last post by:
Hello, I'm interested in establishing the best way to pass information between a vb script and a .net application. We have a VbScript that runs on a users pc every time a phone call is routed...
10
by: Noozer | last post by:
Below is some ASP, HTML and javascript. It is part of a page used to maintain a small database. This code did work at one time, but has since stopped. For some reason the data on my form is not...
3
by: A Ward | last post by:
I am trying to find a way to have multiple seperate ASP.Net applications where I can response.redirect() to a second web application and pass information. From what I have tried: * HTTP-GET - I...
5
by: Paul | last post by:
Just wondering if someone could provide an example of passing a variable from the code behind to javascript in vb. I want to have one control have focus with the page loading with one condition...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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:
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...

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.