473,765 Members | 2,015 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 9201

<op*********@ya hoo.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.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:

theArrayReceive d = $_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=theA rray; and on the other end say theArrayReceive d=
$_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_regist er( "_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.ph p?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)?
theArrayReceive d = $_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*********@ya hoo.com> wrote in message
news:11******** *************@g 43g2000cwa.goog legroups.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_regist er( "_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_n ame_you_choose'] =
the_value_or_va riable_to_be_as signed_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_add ress';
in the using page:
$myAge = $_SESSION['my_address'];

The variable $myAge will contain the value 'this_is_my_add ress'.

Example 2:
in the setting page:
$theArray = array();
$theArray['my_address'] = 'this_is_my_add ress';
$theArray['my_name'] = 'this_is_my_nam e';
$_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_usi ng_page?thevalu es=<?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*********@yah oo.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*******@attgl obal.net
=============== ===
Jul 24 '05 #5

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

Similar topics

3
45065
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 and format strings from 2 different bound columns. I know I could do this using session variables, but I really want to do it using query string parameters. Anyone know a way to do this?
1
7436
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 which users enter numbers to be calculated into a square footage cost. Upon submitting, the results page uses ASP to give the total and the chance to add the new totalled item to the cart or try a new calculation. Part of the cart's software has a...
1
11496
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 a hyperlink to edit each record by passing it's record id to another page. Loop through a set of files on a server and have a hyperlink to download a file via a stream on another page by passing its filename
5
4510
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 a hyperlink to edit each record by passing it's record id to another page. Loop through a set of files on a server and have a hyperlink to download a file via a stream on another page by passing its filename
0
1142
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 + &MR={0 What alteration do i need to make to have this work Thanks Dave
4
9354
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 Customer</asp:HyperLink> But when the page runs it shows text only "View Customer" without hyperlink. This is what it was rendered in the page source <a id="hrefView" class="main" style="color:Blue;">View Customer</a>
19
3559
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 to here as page_2). I need to cache the value of the link's text (hyperlink.text property) so that I can use it in the page_load event of page_2. I've thought of using a hidden field and then calling Request.Form("hdnClickedLinkText") in the...
3
2090
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 Hyperlink arguments or parameters. example http://www.something.com/exam.aspx?i=387964908&m=2347&rr=y&source=hon999 However, I have not been able to find any documentation or help on how the called page actually can retrieve or read those arguments...
1
2503
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> <script type="text/javascript"> function favBrowser()
0
9398
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
10160
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
9832
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...
0
8831
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...
1
7378
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
5275
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
5421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2805
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.