473,836 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re-using POST data

25 New Member
Hi. I'm new to PHP but I'm making progress.

However, I'd like to know if I can use all the data in the $_POST array and send to the next page.
Essentially, I perform a check of the content (which can vary), before sending it on to another page which will handle the real processing of the required information.

Can this be done easily, or do I have to extract all the individdual paramteres and re-process them somehow to pass on to the next page.

My Post data contains nested arrays.

What are your recomendations?

Aug 29 '06 #1
17 6080
268 Contributor
I f u want to get the variable multiple page using SESSION to get the value all the pages
Aug 29 '06 #2
4,258 Recognized Expert Specialist
Actually, there are 3 ways to accomplish this:
  • Store the variables in the $_SESSION array. That way the called script can retrieve them also via the $_SESSION array. To use this, you must have called session_start() in order to be able to use the array.
  • Use the $_GET array. In this case you construct a URL of the script to be called with the parameters concatenated, e.g. "form.php?v1=va r1&v2=var2 etc". The form.php script can now retrieve the values via the $_GET array.
  • Use the $_POST array. To use this you also construct the URL as in the previous, but now you pass it to CURL with the POST option. The receiving form.php can now access the values via the $_POST array.

Take your pick!

Ronald :cool:
Aug 29 '06 #3
9,065 Recognized Expert Moderator Expert
  • Use the $_POST array. To use this you also construct the URL as in the previous, but now you pass it to CURL with the POST option. The receiving form.php can now access the values via the $_POST array.
Ronald, could you go into a little more detail about this method please? :-)
Aug 29 '06 #4
4,258 Recognized Expert Specialist
Glad to, Banfa. I'll just start with the definition given by Zend:
cURL and libcurl are libaries that allow a webserver to transfer files with a remote computer using a variety of Internet protocols. The libaries are highly configurable, allowing practically any type of client-server request to be peformed. By using these tools, a webserver can act as a client, creating and responding to requests using any technology built on HTTP, like XML-RPC, SOAP, or WebDAV.
And one by Wikipedia:
cURL is a command line tool for transferring files with URL syntax, supporting FTP, FTPS, HTTP, HTTPS, TFTP, Telnet, DICT, FILE and LDAP. cURL supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading, Kerberos, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM and Negotiate for HTTP and kerberos4 for FTP), file transfer resume, http proxy tunneling and many other features. cURL is open source/free software distributed under MIT License.

The main purpose and use for curl the command line tool is to automate unattended file transfers or sequences of operations. It is for example a good tool for simulating a user's actions at a web browser.

Libcurl is the corresponding library/API that users may incorporate into their programs; cURL acts as a stand-alone wrapper to the libcurl library. libcurl is being used to provide URL transfer capabilities to numerous applications, Open Source as well as many commercial ones.

More than 30 different language bindings are available for libcurl.
Curl is free and open software that compiles under a wide variety of operating systems. Currently there are approx. 35 language bindings available.

Following addresses the reply I gave in this forum about POSTing via CURL. Just 2 samples (sending and receiving) that I got from the Zend site and use myself (adapted to my site):
[PHP]-------------- POST variables via curl ----------------------------------
// A very simple PHP example that sends a HTTP POST to a remote site

$ch = curl_init();

curl_setopt($ch , CURLOPT_URL,"ht tp://www.mysite.com/tester.phtml");
curl_setopt($ch , CURLOPT_POST, 1);
curl_setopt($ch , CURLOPT_POSTFIE LDS,
"postvar1=value 1&postvar2=valu e2&postvar3=val ue3");
curl_exec ($ch);
curl_close ($ch);
------------------ and this is to test the $_POST array ---------------

echo '<h3>Form variables I received: </h3>';

echo '<pre>';
print_r ($_POST);
echo '</pre>';

There is quite some information about cURL, see:

The developers of Curl (Daniel Stenberg and 500 others): http://curl.haxx.se/libcurl/php/
PHP site: http://nl3.php.net/manual/en/ref.curl.php
Zend site: http://www.zend.com/pecl/tutorials/curl.php
PHP-It site: http ://www.phpit.net/article/using-curl-php/
PHP Freaks site: http://www.phpfreaks.c om/tutorials/49/1.php
Higherpass site: http://www.higherpass.com/php/tutori...ote-Servers/1/ and http://www.higherpass.com/php/Tutori...emote-Servers/
Yahoo site: http://developer.yahoo.com/php/howto-reqRestPhp.html
bobcares.com: http://bobcares.com/article47.html

But, when you look around (e.g. Google, Yahoo), you'll find many more stuff on the net.

When you want, I can send you a Word document "CURL: Client URL Library" by Mr. MA Razzaque Rupom.

Ronald :cool:
Aug 29 '06 #5
1,208 Recognized Expert Top Contributor
you don't have to go as far as that just to retrieve these values my friends...

use hidden text fields in a form if your using a form.

if your not using a form make the links call the form to submit.
Aug 29 '06 #6
4,258 Recognized Expert Specialist
That was not the point. Question was just how to pass data from one page to another. Making an extra form requires the user to click an extra link, and that was not the point here.
Passing it via the URL exposes your parameter data to an outside onlooker.

Posting it without using a form is the issue here, hence CURL.

Ronald :cool:
Aug 29 '06 #7
25 New Member
thanks all for your detailed replies.
I'll have to do some research on these approaches due to inexperience, but thanks for guiding me in the right direction.
Aug 29 '06 #8
4 New Member
Wow great thread. I actually have a similar problem.

While running a php script on user-supplied info from a form, I need to send some of that data to a php script running on another server (which does a database lookup), and get back a response.

This is the way that I've thought of (and successfully tried) doing it

$foo = urlencode($food ata);
$bar = urlencode($bard ata);

$response = file_get_conten ts("http://example.com?foo =$foo&bar=$bar" );
if ($response == $checkVal)
?>[/php]And this works very nicely, thank you! However, I am concerned about the contents of the variables, they are originally part of user input, so I put them through urlencode() first, which I'd rather not do. Is there any way I can put these variables into a POST action and get back the results with code that is as simple (or as close to as simple) as the above snippet???

Thanks so much for your help.
Sep 13 '06 #9
1,208 Recognized Expert Top Contributor
your mistaking my post ronverdonk you can have javascripts submit the form using POST method which would in turn not put it in the address thanks have a good day.
Sep 13 '06 #10

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

Similar topics

by: Nel | last post by:
I have a question related to the "security" issues posed by Globals ON. It is good programming technique IMO to initialise variables, even if it's just $foo = 0; $bar = ""; Surely it would be better to promote better programming than rely on PHP to compensate for lazy programming?
by: Craig Bailey | last post by:
Anyone recommend a good script editor for Mac OS X? Just finished a 4-day PHP class in front of a Windows machine, and liked the editor we used. Don't recall the name, but it gave line numbers as well as some color coding, etc. Having trouble finding the same in an editor that'll run on OS X. -- Floydian Slip(tm) - "Broadcasting from the dark side of the moon"
by: James | last post by:
My form and results are on one page. If I use : if ($Company) { $query = "Select Company, Contact From tblworking Where ID = $Company Order By Company ASC"; }
by: Alan Walkington | last post by:
Folks: How can I get an /exec'ed/ process to run in the background on an XP box? I have a monitor-like process which I am starting as 'exec("something.exe");' and, of course the exec function blocks until something.exe terminates. Just what I /don't/ want. (Wouldn't an & be nice here! Sigh) I need something.exe to disconnect and run in the background while I
by: John Ryan | last post by:
What PHP code would I use to check if submitted sites to my directory actually exist?? I want to use something that can return the server code to me, ie HTTP 300 OK, or whatever. Can I do this with sockets??
by: joost | last post by:
Hello, I'm kind of new to mySQL but more used to Sybase/PHP What is illegal about this query or can i not use combined query's in mySQL? DELETE FROM manufacturers WHERE manufacturers_id NOT IN ( SELECT manufacturers_id FROM products )
by: Clarice Almeida Hughes | last post by:
tenho um index onde tenho o link pro arq css, como sao visualizados pelo include todas as paginas aderem ao css linkado no index. so q eu preciso de alguns links com outras cores no css, o q devo fazer?
by: JW | last post by:
I wanted have this as part of a flood control script: <? echo ("Flood control in place - please wait " . $floodinterval . " seconds between postings."); sleep(5); // go back two pages echo "<script>window.history.go(-2);</script>"; exit; ?>
by: Frans Schmidt | last post by:
I want to make a new database with several tables, so I did the following: <?php CREATE DATABASE bedrijf; CREATE TABLE werknemers (voornaam varchar(15), achternaam varchar(20), leeftijd tinyint(3), adres varchar(30), woonplaats varchar(20),
by: sky2070 | last post by:
Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ')' in c:\inetpub\wwwroot\session.php on line 19 can anyone tell me what is wrong with this code??? <? // Define the Session class class Session { // Define the properties:
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...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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,...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.