473,503 Members | 3,884 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hyperlink and passing of variables.

Hello,

I know three ways to pass variables form one page to another. The first
one is to declare and set session variable. In this case if one goes to
another page (by clicking on hyperlink or pressing a button) value of a
session variable will be automatically seen on the new page. The second
way is to set hidden variables in the form and go to new page by
execution of this form (press a button or enter), and the last way,
which I know, is in the declaration of hyperlink after name of a new
page put after "?" names and values of variables. Sometimes I need
to use the third way. However I do not like that after new page is
loaded in the address line of browser one can see all variables (names
and values). Can one avoid this problem?

Jul 24 '05 #1
4 9192

<op*********@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hello,

I know three ways to pass variables form one page to another. The first
one is to declare and set session variable.
Assuming that you have session_start() at the beginning of both pages?
In this case if one goes to
another page (by clicking on hyperlink or pressing a button) value of a
session variable will be automatically seen on the new page. The second
way is to set hidden variables in the form and go to new page by
execution of this form (press a button or enter),
???? Hitting the enter button will only have variables on that page unless
you do what you call the first or third methods. What do you mean here?
and the last way,
which I know, is in the declaration of hyperlink after name of a new
page put after "?" names and values of variables. Sometimes I need
to use the third way. However I do not like that after new page is
loaded in the address line of browser one can see all variables (names
and values). Can one avoid this problem?


Yes. Create a variable which is an array. Put in the values you want for
each variable as:

theArray['first_var'] = first value;

Then create a single session variable which is $_SESSION['theValues'] =
$theArray and pass that single array via the ?thevalues = $theArray.

At the other end you say:

theArrayReceived = $_GET['thevalues'];

and you have an array that you can get the values via the indexing.

I haven't tried it, but it might also work without the creation of the
session variable step. IOW, say

?thevalues=theArray; and on the other end say theArrayReceived=
$_GET['thevalues'];

When I get home from vacation, I will try it. If you try this and it works
without the session variable step, please let me know.

Shelly
Jul 24 '05 #2
I am not sure, that I understood what I need to do.
Create a variable which is an array. Put in the values you want for
each variable as:
theArray['first_var'] = first value; OK. Let say in the file "first.php" I write:
theArray[first] = "aaaa";
theArray[second] = "bbb";
Is it what I need to do?
Then create a single session variable which is $_SESSION['theValues'] =
$theArray What does it mean "to create session variable"? I think I need to
open session by "session_start();" and then I register a session
variable by "session_register( "_SESSION" );", where _SESSION is
the variable name. Do I correctly understand? By the way, what for I
need to put "magical" symbol "_" in the variable name?
and pass that single array via the ?thevalues = $theArray. Do you mean that I need to create hyperlink in the following way?
<a href="second.php?thevalues = $theArray"> Press here </a>
At the other end you say: Under "other end" do you understand the second file (file where I want
to pass variable values)?
theArrayReceived = $_GET['thevalues'];

This line I do not understand. I sees symbol "$" and suppose that
"_GET" is variable name. But I think that my supposition is wrong
since variable with such name never has been declared... How this line
should be understood?

Jul 24 '05 #3

<op*********@yahoo.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
I am not sure, that I understood what I need to do.
Create a variable which is an array. Put in the values you want for
each variable as:
theArray['first_var'] = first value;

OK. Let say in the file "first.php" I write:
theArray[first] = "aaaa";
theArray[second] = "bbb";
Is it what I need to do?
Then create a single session variable which is $_SESSION['theValues'] =
$theArray

What does it mean "to create session variable"? I think I need to
open session by "session_start();" and then I register a session
variable by "session_register( "_SESSION" );", where _SESSION is
the variable name. Do I correctly understand? By the way, what for I
need to put "magical" symbol "_" in the variable name?


No. Here it is (assuming your are at PHP 4 or greater).

To create the session variable you do:

$_SESSION['the_variable_name_you_choose'] =
the_value_or_variable_to_be_assigned_to_it;

The variable name is anything you want. All you need be consistent about is
using the same index in both the setting and the using pages.

Example 1:
in the setting page
$_SESSION['my_address'] = 'this_is_my_address';
in the using page:
$myAge = $_SESSION['my_address'];

The variable $myAge will contain the value 'this_is_my_address'.

Example 2:
in the setting page:
$theArray = array();
$theArray['my_address'] = 'this_is_my_address';
$theArray['my_name'] = 'this_is_my_name';
$_SESSION['my_values'] = $theArray;

in the using page:
$anArray = $_SESSION['my_values'];
and you have
$anArray['my_address'] and $anArray['my_name'] having the correct values.

What I was asking was that in example 2 if you did
<a href=URL_of_using_page?thevalues=<?php echo $theArray ?> >
and in the using page use
$anArray = $_GET['thevalues'];
would that work? I think so, but am not sure. I am sure that example 2
works.

Shelly
Jul 24 '05 #4
op*********@yahoo.com wrote:
Hello,

I know three ways to pass variables form one page to another. The first
one is to declare and set session variable. In this case if one goes to
another page (by clicking on hyperlink or pressing a button) value of a
session variable will be automatically seen on the new page. The second
way is to set hidden variables in the form and go to new page by
execution of this form (press a button or enter), and the last way,
which I know, is in the declaration of hyperlink after name of a new
page put after "?" names and values of variables. Sometimes I need
to use the third way. However I do not like that after new page is
loaded in the address line of browser one can see all variables (names
and values). Can one avoid this problem?


You can't. When using the $_GET method to pass variables from one page to
another, they will end up in the location link (and can be changed by the users).

You're best bet is to use sessions.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 24 '05 #5

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

Similar topics

3
45034
by: bpschmid | last post by:
Ive got a datagrid with a hyperlink column. I want to click on that column and go to another page, but here's the kicker, I need and want to pass not one, but two different query string parameters...
1
7421
by: Newbie | last post by:
OK, this may be impossible since I'm using 3rd party shopping cart ASP software, but I've been able to finagle a lot of other stuff I thought wouldn't work, so here we go: I'm using a form in...
1
11411
by: Fresh Air Rider | last post by:
Could anyone please tell me how I can call a function from a hyperlink in C# ? Examples of scenarios where this would be useful include :- Loop through a set of records in a repeater and have...
5
4493
by: Fresh Air Rider | last post by:
Could anyone please tell me how I can call a function from a hyperlink in C# ? Examples of scenarios where this would be useful include :- Loop through a set of records in a repeater and have...
0
1132
by: Dave Bailey | last post by:
I am using the following entry in the URL format string section of the property builder on a datagrid. I would like to pass the two variables as shgown mrForm.aspx?sessionid= + Session.SessionID...
4
9340
by: Lan H. Nguyen | last post by:
I have this line of code in my .aspx page <asp:HyperLink ID="hrefView" CssClass="main" ForeColor="blue" Runat="server" NavigateUrl='<%# "View.aspx?id=" + ID.ToString()%>'>View...
19
3464
by: Joe | last post by:
I have an aspx page (referred to here as page_1) with a datagrid whose first column contains hyperlinks. When a user clicks one of these hyperlinks, he will navigate to another aspx page (referred...
3
2076
by: Hugh O | last post by:
Hi, I am implementing an internet app via Visual Studio.Net 2003 using VB.Net. There are numerous references within the Help facilities for using or passing data between Internet pages via...
1
2484
by: abertay | last post by:
Hi friends...I need our help.I'm stuck with this code... can some one tell me how can pass a javascript variable into hyperlink along with a php varaible? Here is my code.. <html> <head>...
0
7063
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...
0
7313
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...
1
6970
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...
0
5558
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,...
1
4987
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...
0
4663
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...
0
3156
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...
0
1489
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 ...
1
720
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.