Hello again,
I have now several consecutive forms in my site which nicely pass variables
in POST, so they won't show up in the header.
Now I have a page people reach after submitting all kinds of information,
from where I offer a link users can click on.
Let's say I have collected several strings and I have put these in an array
and serialized that.
$var[0]='John Doe';
$var[1]='2345 Livnigston Ave';
$var[2]='Boston';
$var[3]='Plumber';
$data = serialize ($var);
When the user clicks the (only) link on this page, all this serialized data
needs to be passed along to the new page.
I did this:
(...)
// $data contains the serialized array
echo "<a href='action.php?data=$data'>go here</a>";
First question: using this method the $data is passed via GET. I would
prefer to keep using POST, and not have ugly tell-tale headers. Is that
possible using PHP? How? [I'd rather not use sessions here which would avoid
the entire datapassing issue.]
Second question: when I echo back $data in the action.php script, it seems a
chunk of the string is missing. Is that due to a limit in length ? How long
a string can be passed as a single var ? Different for GET vs POST ? Like it
is unserialize returns FALSE, which makes sense, as the data is incomplete.
Help appreciated. If you need more specifics, I'm happy to elaborate.
Pjotr 3 2263
"Pjotr Wedersteers" wrote: Hello again,
I have now several consecutive forms in my site which nicely pass variables in POST, so they won’t show up in the header. Now I have a page people reach after submitting all kinds of information, from where I offer a link users can click on. Let’s say I have collected several strings and I have put these in an array and serialized that.
$var[0]=’John Doe’; $var[1]=’2345 Livnigston Ave’; $var[2]=’Boston’; $var[3]=’Plumber’; $data = serialize ($var);
When the user clicks the (only) link on this page, all this
serialized data needs to be passed along to the new page. I did this:
(...) // $data contains the serialized array echo "<a href=’action.php?data=$data’>go here</a>";
First question: using this method the $data is passed via GET. I
would prefer to keep using POST, and not have ugly tell-tale headers. Is that possible using PHP? How? [I’d rather not use sessions here which would avoid the entire datapassing issue.]
Second question: when I echo back $data in the action.php script,
it seems a chunk of the string is missing. Is that due to a limit in length ?
How long a string can be passed as a single var ? Different for GET vs POST
? Like it is unserialize returns FALSE, which makes sense, as the data is incomplete.
Help appreciated. If you need more specifics, I’m happy to elaborate. Pjotr
Question 1: Instead of using a link, you have the option of using a
button (if that is ok) and put that in a form and use post.
Question 2: I am not sure, but make sure to urlencode your serialized
string when attaching it to url.
-- http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-Passing-...ict145063.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=485854
"Pjotr Wedersteers" <x3****@westerterp.com> wrote in message
news:<41***********************@news.xs4all.nl>... I have now several consecutive forms in my site which nicely pass variables in POST, so they won't show up in the header. Now I have a page people reach after submitting all kinds of information, from where I offer a link users can click on. Let's say I have collected several strings and I have put these in an array and serialized that.
$var[0]='John Doe'; $var[1]='2345 Livnigston Ave'; $var[2]='Boston'; $var[3]='Plumber'; $data = serialize ($var);
When the user clicks the (only) link on this page, all this serialized data needs to be passed along to the new page. I did this:
(...) // $data contains the serialized array echo "<a href='action.php?data=$data'>go here</a>";
First question: using this method the $data is passed via GET. I would prefer to keep using POST, and not have ugly tell-tale headers. Is that possible using PHP?
Sure. Just replace the link with a form, and don't forget to
urlencode() the serialized array:
$var[0]='John Doe';
$var[1]='2345 Livnigston Ave';
$var[2]='Boston';
$var[3]='Plumber';
$data = urlencode(serialize($var));
echo <<<ENDOFFORM
<form method="post" action="action.php">
<input type="hidden" name="data" value="$data">
<input type="submit" value="Go!">
</form>
ENDOFFORM;
And in action.php, you can do:
$var = unserialize(urldecode($_POST['data']));
when I echo back $data in the action.php script, it seems a chunk of the string is missing. Is that due to a limit in length ?
Most likely, it is due to the fact that you didn't urlencode() the
serialized array, so spaces, double quotes, colons, and semicolons
conspired to mess up your variable.
How long a string can be passed as a single var ?
I don't think this is a right question to ask. If I remember correctly,
there is a limit to the number of characters in a GET request.
Different for GET vs POST ?
Definitely. POST requests can be much longer than GET requests.
Cheers,
NC
Nikolai Chuvakhin wrote: "Pjotr Wedersteers" <x3****@westerterp.com> wrote in message news:<41***********************@news.xs4all.nl>... I have now several consecutive forms in my site which nicely pass variables in POST, so they won't show up in the header. Now I have a page people reach after submitting all kinds of information, from where I offer a link users can click on. Let's say I have collected several strings and I have put these in an array and serialized that.
$var[0]='John Doe'; $var[1]='2345 Livnigston Ave'; $var[2]='Boston'; $var[3]='Plumber'; $data = serialize ($var);
When the user clicks the (only) link on this page, all this serialized data needs to be passed along to the new page. I did this:
(...) // $data contains the serialized array echo "<a href='action.php?data=$data'>go here</a>";
First question: using this method the $data is passed via GET. I would prefer to keep using POST, and not have ugly tell-tale headers. Is that possible using PHP?
Sure. Just replace the link with a form, and don't forget to urlencode() the serialized array:
$var[0]='John Doe'; $var[1]='2345 Livnigston Ave'; $var[2]='Boston'; $var[3]='Plumber'; $data = urlencode(serialize($var)); echo <<<ENDOFFORM <form method="post" action="action.php"> <input type="hidden" name="data" value="$data"> <input type="submit" value="Go!"> </form> ENDOFFORM;
And in action.php, you can do:
$var = unserialize(urldecode($_POST['data']));
when I echo back $data in the action.php script, it seems a chunk of the string is missing. Is that due to a limit in length ?
Most likely, it is due to the fact that you didn't urlencode() the serialized array, so spaces, double quotes, colons, and semicolons conspired to mess up your variable.
How long a string can be passed as a single var ?
I don't think this is a right question to ask. If I remember correctly, there is a limit to the number of characters in a GET request.
Different for GET vs POST ?
Definitely. POST requests can be much longer than GET requests.
Cheers, NC
Amazing how one often misses the easiest of things. Never thought of a form
with just a hidden field.
Cleared it all up for me, thanks a bunch really, Nikolai! You rock.
regards
Pjotr This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Richard Ragon |
last post by:
Hows does the passing variables from page to page work?
Specifically, when you type in a URL like:
http://www.someurl.com/test.php?someVar=20
How does the next page get, and use the variable?...
|
by: Bart Plessers \(artabel\) |
last post by:
Hello,
Currently developping a site, where I use some session variables.
The site is located at my home computer.
Because I have a dynamic IP adress, I use no-ip (www.no-ip.org) to have my...
|
by: webguynow |
last post by:
My Dynamic variables print out, same as strings but aren't the same.
They are not correct when using them as DB.connection vars.
I was using my own routine, that read in string values from a...
|
by: Mark Anderson |
last post by:
I have code to develop result page links (like a search engine) for some
results being passed from a database where I've no server-sdide acces -
thus JS.
The code is below and works fine except...
|
by: Jim Banks |
last post by:
Greetings
I'm opening a pop up window with a html form, (in one document) and I want to pass a variable to the html form called from the hyperlink.
Here's the code I'm using to pop up the...
|
by: Khai |
last post by:
First off, yes, I understand the crapload of tutorials out there, (well,
rather, I understand there /are/ a crapload of tutorials out there), the
problem is my comprehension.
I'm trying to pass...
|
by: Bob Bruyn |
last post by:
I've recently installed Apache 2 and php 5.2 on my WIndows XP
machine. Everything is up and running.
I'm passing some vars via the URL. It works fine online:...
|
by: johnjsforum |
last post by:
Buddies,
I have a web page to create HTML buttons dynamically as in the “formDivColorPicker” function
////////////////////////////////////////////////////////////////////////////////////...
|
by: goodguyjam |
last post by:
Hi all,
I'm having trouble with mysql.
I've just finished my php coding for HTTP authentication and with some help am now getting a login window pop up whenever I click on a link on my website...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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,...
|
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...
| |