473,776 Members | 1,665 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Does $_POST survive script hopping?

Suppose I have an HTML form that sends data to a PHP script, "post"
method.

If this script generates a page with a link to another script, will the
latter script get the former's $_POST data when the user clicks on the
link?

If not, is there a straightforward way (i.e.: no saving to files or
cookies) to "post" the data to the latter script without using a form?

TIA for your comments...

Feb 5 '08 #1
14 1585
On Wed, 06 Feb 2008 00:15:42 +0100, Zorque <zo**@127.0.0.1 wrote:
Suppose I have an HTML form that sends data to a PHP script, "post"
method.

If this script generates a page with a link to another script, will the
latter script get the former's $_POST data when the user clicks on the
link?
No.
If not, is there a straightforward way (i.e.: no saving to files or
cookies) to "post" the data to the latter script without using a form?
No. Either use sessions or curl in some way to achieve this.

--
Rik Wasmus
Feb 5 '08 #2
Zorque wrote:
Suppose I have an HTML form that sends data to a PHP script, "post"
method.

If this script generates a page with a link to another script, will the
latter script get the former's $_POST data when the user clicks on the
link?
No. Each request is new.
If not, is there a straightforward way (i.e.: no saving to files or
cookies) to "post" the data to the latter script without using a form?

TIA for your comments...

cURL can do it, but may not be what you want. Otherwise save in the
session or use a form.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Feb 5 '08 #3
Zorque wrote:
If this script generates a page with a link to another script, will the
latter script get the former's $_POST data when the user clicks on the
link?
No. If you read about how HTTP works, you'll find that values are only
posted once.
If not, is there a straightforward way (i.e.: no saving to files or
cookies) to "post" the data to the latter script without using a form?
Several methods exist. One is using cookies, another one is saving to a
file...

I think that the answer you want is "sessions". Store things on a session
variable, and the second script will find those sessions variables with
their values. Do read http://php.net/session .

Cheers,
--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

Un ordenador no es un televisor ni un microondas, es una herramienta
compleja.
Feb 5 '08 #4
In article <fo**********@a ioe.org>, Zorque <zo**@127.0.0.1 wrote:
>Suppose I have an HTML form that sends data to a PHP script, "post"
method.

If this script generates a page with a link to another script, will the
latter script get the former's $_POST data when the user clicks on the
link?
Not unless you save the post in the local session array:

$_SESSION['post'] = $_POST;

Then in the other script you'd simply retrieve the post data as

$post = &$_SESSION['post'];

Be sure you do all the necessary initializations *each* time *any*
script is invoked, or the $_SESSION functionality won't work. All
my scripts execute these statements before doing anything else:

session_save_pa th("/home/myaccountpath/sessions");
session_name('u ser_settings');
session_start() ;
if (session_id() == 'deleted') session_regener ate_id(true);
>If not, is there a straightforward way (i.e.: no saving to files or
cookies) to "post" the data to the latter script without using a form?
Well, if you don't want to save files, then $_SESSION isn't for you,
because that automatically saves a session file.

-A
Feb 5 '08 #5
axlq wrote:
In article <fo**********@a ioe.org>, Zorque <zo**@127.0.0.1 wrote:
>Suppose I have an HTML form that sends data to a PHP script, "post"
method.

If this script generates a page with a link to another script, will the
latter script get the former's $_POST data when the user clicks on the
link?

Not unless you save the post in the local session array:

$_SESSION['post'] = $_POST;

Then in the other script you'd simply retrieve the post data as

$post = &$_SESSION['post'];

Be sure you do all the necessary initializations *each* time *any*
script is invoked, or the $_SESSION functionality won't work. All
my scripts execute these statements before doing anything else:

session_save_pa th("/home/myaccountpath/sessions");
session_name('u ser_settings');
session_start() ;
if (session_id() == 'deleted') session_regener ate_id(true);
Wrong. All that you need is session_start() . But it needs to be at the
top of your script, before ANYTHING else (including white space) is output.
>If not, is there a straightforward way (i.e.: no saving to files or
cookies) to "post" the data to the latter script without using a form?

Well, if you don't want to save files, then $_SESSION isn't for you,
because that automatically saves a session file.

-A

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Feb 6 '08 #6
In article <i4************ *************** ***@comcast.com >,
Jerry Stuckle <js*******@attg lobal.netwrote:
>my scripts execute these statements before doing anything else:

session_save_p ath("/home/myaccountpath/sessions");
session_name(' user_settings') ;
session_start( );
if (session_id() == 'deleted') session_regener ate_id(true);

Wrong. All that you need is session_start() .
Wrong.

Perhaps different ISPs behave differently. Those lines above are
there because they are necessary in my case, and in general cases it
does no harm to include them.

session_save_pa th() is necessary because the default session path
results in sessions that last 20 minutes. There are likely other
ways to cause the session to last as long as the user's browser is
open. Setting one's own path is one way to do it.

session_name() isn't really necessary, but does give a meaningful
name to the cookie set in the user's browser, if the user cares to
look. Since *I* am that sort of user who looks at my cookies, I do
things to cater to other users like me.

session_start() is necessary, but can't occur until
session_save_pa th and session_name have been called.

The 'if' statement above is necessary. When a user logs out and
session_destroy () is called, a session file on the server still
exists but is renamed to 'deleted'. The session cookie is renamed
to 'deleted' (at least it is in Opera). When multiple users access
the site with a session cookie named 'deleted', they will end up
sharing session data. I have tested and verified this behavior, as
well as verified it with the PHP support folks.

You may want to argue about it, but I doubt you'd be able to argue
successfully that the above 4 lines aren't necessary for my site.

-A
Feb 6 '08 #7
Thanks, everybody. I really need to read up on sessions.

But in this case I think I might take another route, following my latest
discovery: HTML forms can have hidden fields with fixed values.

So the first script could dump its $_POST as hidden fields of a form on
the page it generates, and the link to the second script could be a
"submit" button.

Feb 6 '08 #8
Zorque wrote:
Thanks, everybody. I really need to read up on sessions.

But in this case I think I might take another route, following my latest
discovery: HTML forms can have hidden fields with fixed values.
Yes, but keep in mind that hidden values can be tampered with by a savvy
user.

Have a look at the "tamper data" and "web developer toolbar" extensions for
firefox and play with your hidden fields.

Sessions are usually prefered because they can't be tampered with, and
they'll save a tiny little bit of bandwidth, as you won't be piggybacking
the data back and forth.

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

MSN:i_********* *************** *@hotmail.com
Jabber:iv****** ***@jabber.org ; iv*********@kde talk.net
Feb 6 '08 #9
Jerry Stuckle wrote:
All that you need is session_start() . But it needs to be at the top of
your script, before ANYTHING else (including white space) is output.
session_start() only needs to be at the top of the script if:

1. You are using cookie-based sessions; *and*
2. You are writing data to a new session.

If you are only reading data from session, or if you are writing data to a
session which you know already exists (e.g. on a page that a user can only
access once they've logged in, where your authentication system uses
sessions) then your call to session_start() does not need to be before
output -- it only has to be before you start using $_SESSION.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 7 days, 18:34.]

Looking Ahead to Perl 6
http://tobyinkster.co.uk/blog/2008/02/05/perl6/
Feb 6 '08 #10

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

Similar topics

1
12303
by: Antoni | last post by:
Hello, I wondered if anyone could further advice? In my script I was trying allow the user to enter a userid and password, and when the users clicks the login button. Pass these values passed to a method login_user, and finally display there record. I was hoping to display the record on this page. I would appreicate some advice if my scrips looks corrects? I unsure about the line if(isset($_POST)){?
14
4337
by: billy.becker | last post by:
I need to save a wav file that is HTTP POSTed to a php page. What does PHP5 do automatically to a POSTed variable when it puts it in the $_POST superglobal array? I haven't been able to find any info on this.... I have a script that does what I want in PERL, but I need to do it in PHP. I think the PERL does something magic when it does this:
5
2064
by: Joe Blow | last post by:
I'm sure I'm missing something blindingly obvious here. I am relatively new to PHP, so excuse dumb mistakes. I a trying to check a form submitted from an earlier page, and check $_POST for empty values. Only some of them are not allowed to be empty, hence the rather lengthy way in which the script is written. If no required fields are empty, then I want another part of the script to function, and the variables to be sent to a database....
3
1409
by: Chris H | last post by:
I have been looking through this script and came across something that I dont quite understand how it functions or is used. Basically its brackets that are added on at the end of a form field value. EXAMPLE: <input name="eid" type="hidden" id="eid" value="<? echo $ses_id; ?>"> in other words what does the brackets pass to the function thats processing the form, basically how is the used.
1
6795
by: Infiliset | last post by:
Hi all! I'm trying to test some php script using the command line php.exe. Is there any way to pass the $_POST variables? I know how to pass the $_GET variables, but I don't know how to do this for the $_POST ones. Thank you all! Matthew
1
6995
by: RDizzle | last post by:
okay. so all i am doing is changing a registration script that uses $_GET to a script that uses $_POST, but the validation script now returns NULL values for all posted vars. What's the deal? NOTE: when i use $_GET the script just works. Thanks in advance for helping a noob.
9
2019
by: lovinlazio9 | last post by:
I've just started messing around with PHP and believe it or not its extremely frustrating haha. Anyway, I wanted to make a simple input form that would display the info after submitting it... The script is a simple html script, which calls a php script passing it the variables which it got by the forms: **************HTML doc. named "insert.htm"************************ <html> <head> <title>HTML Form</title>
5
3875
Tarantulus
by: Tarantulus | last post by:
Hi, ok, quick description of the problem, I'm trying to reference the postdata from some checkboxes. Unfortunately the checkboxes are dynamically generated therefore I don't know how many there are and thus can't name them individually. I remember reading that naming them with square brackets (as "name") will automatically create an array in the postdata (meaning $_POST is an array) is this true? anyway, the fact is that my checkboxes...
2
1836
chunk1978
by: chunk1978 | last post by:
i wrote a custom PHP script last year and everything worked perfectly... recently my webserver upgraded to PHP 5 and now my script doesn't work properly. what the script does is: users fill out info and optionally can upload images, the user receives and email receipt of all the data they just submitted, and i'm suppose to receive their information in my email. what still works is that the user will receive their receipt and the images...
0
9628
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10292
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10061
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9923
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7471
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6722
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4031
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2860
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.