473,670 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing vars in a link ?

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.ph p?data=$data'>g o 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
Jul 17 '05 #1
3 2287
"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.ph p?data=$data’>g o
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
Jul 17 '05 #2
"Pjotr Wedersteers" <x3****@westert erp.com> wrote in message
news:<41******* *************** *@news.xs4all.n l>...

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.ph p?data=$data'>g o 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(seria lize($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(url decode($_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
Jul 17 '05 #3
Nikolai Chuvakhin wrote:
"Pjotr Wedersteers" <x3****@westert erp.com> wrote in message
news:<41******* *************** *@news.xs4all.n l>...

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.ph p?data=$data'>g o 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(seria lize($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(url decode($_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
Jul 17 '05 #4

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

Similar topics

3
3042
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? Sorry for the dumb question.. Thanks
1
2786
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 own custom domain name (pvo.no-ip.org) My ISP blocks port 80, so website runs at port 4040 The service no-ip offers "Mask / Cloaking Options": every request to my domain is "wrapped in a frame", so end user can only see one URL in browser.
1
1389
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 config file, that had entries like host=localhost etc, etc. After reading, I used explode with "=" as a separator,... then finally created some dynamic vars $$key=$val They are valid, it seems and printout/echo correct normal values:...
6
1874
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 the function in the onClick event of the link being written on screen fails indicating 'theForm' as being passed through is 'not defined'. The form is being passed as "document.resultAdd" and can be checked as arriving in my function. So what...
5
2164
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 window and call the form. In this particular instance, a city name is what I have to pass to the form Chapter.htm. <html> <head>
7
2783
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 variables, and can do so just fine with a URL, and $_GET. What I would like to learn, and be very adept at using is the Form functions and how you pass through that. The problem in my comprehending this, is how does the original page know how...
2
3442
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: http://www.torusdesign.nl/spry/test.php?folder=schilderijen/vrij_werk&navColor=SchilderijenNAV This is the code: <?php echo $folder; ?> <?php echo $navColor; ?>
1
2268
by: johnjsforum | last post by:
Buddies, I have a web page to create HTML buttons dynamically as in the “formDivColorPicker” function //////////////////////////////////////////////////////////////////////////////////// version 1 : using global variables ////////////////////////////////////////////////////////////////// var _textField, _divColorPicker; // global vars window.onload = function() { _textField = document.getElementById('htxaMessage'); // fill...
6
2614
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 that directs to Auth.php. The code for this is below: <?php /* Program: Auth.php * Desc: Program that prompts for a user name and * password from the user using HTTP authentication.
0
8468
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
8386
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,...
0
8901
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...
0
8814
jinu1996
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...
0
7415
agi2029
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...
0
5683
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();...
0
4209
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...
0
4390
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2041
muto222
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.