473,395 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to Use HTML Parameters in PHP?

Hi,

I'm trying to create a page where clicking on a link will go to a php
page and pass it parameters so it can determine which link was
clicked. I don't want to use any client side scripting for this, so
making the link act as a submit button via javascript won't do.

Unfortunately, this isn't working. Here is the sample code.

First the page with the links:

<html>
<body>
<a href="dest.php?link=Link1">Link 1</a>
<a href="dest.php?link=Link2">Link 2</a>
</body>
</html>

And the php script:

<html>
<body>
<? if ($_GET['Link1'])
echo "Link 1 Clicked";
else
echo "Link 2 Clicked"; ?>
</body>
</html>
In the above script, also tried $_POST, but php is not picking up the
variables. What am I doing wrong?
Thanks.
Jul 17 '05 #1
2 55087
On Sat, 03 Jan 2004 20:26:08 -0800, xmp333 wrote:
I'm trying to create a page where clicking on a link will go to a php
page and pass it parameters so it can determine which link was
clicked. I don't want to use any client side scripting for this, so
making the link act as a submit button via javascript won't do.
Unfortunately, this isn't working. Here is the sample code.
First the page with the links:

<html>
<body>
<a href="dest.php?link=Link1">Link 1</a>
<a href="dest.php?link=Link2">Link 2</a>
</body>
</html>
So clicking on either link will send a value to the action page.
That value will be in the variable "link".
And the php script:

<html>
<body>
<? if ($_GET['Link1'])


There won't be anything in there because you didn't pass a variable
named 'Link1' you passed a variable named 'link'.

The paramater is passed as "link" not as "Link1" or "Link2". The
value of $_GET['link'] will contain either "Link1" or "Link2"
depending on what link was clicked.

The value of $_GET['Link1'] will always be null the way you wrote the
code.

Ed
Jul 17 '05 #2
Ed Seedhouse wrote:
On Sat, 03 Jan 2004 20:26:08 -0800, xmp333 wrote:

I'm trying to create a page where clicking on a link will go to a php
page and pass it parameters so it can determine which link was
clicked. I don't want to use any client side scripting for this, so
making the link act as a submit button via javascript won't do.
Unfortunately, this isn't working. Here is the sample code.
First the page with the links:

<html>
<body>
<a href="dest.php?link=Link1">Link 1</a>
<a href="dest.php?link=Link2">Link 2</a>
</body>
</html>

So clicking on either link will send a value to the action page.
That value will be in the variable "link".

And the php script:

<html>
<body>
<? if ($_GET['Link1'])

There won't be anything in there because you didn't pass a variable
named 'Link1' you passed a variable named 'link'.

The paramater is passed as "link" not as "Link1" or "Link2". The
value of $_GET['link'] will contain either "Link1" or "Link2"
depending on what link was clicked.

The value of $_GET['Link1'] will always be null the way you wrote the
code.

Ed

You'd probably want to do something in your script like:

== start ========
<html>
<body>
<?
if ($_GET['link']=="Link1"){
echo "Link 1 Clicked";
} else {
echo "Link 2 Clicked";
}
?>
</body>
</html>
== end =========

If you have more than two links, it'd be good to use a switch statement.
http://www.php.net/manual/en/control...res.switch.php

Regards,

- Dan
dantripp.com
Jul 17 '05 #3

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

Similar topics

2
by: Kai I. H. | last post by:
Hi, I have an activeX control (programmed with c++) which is displayed in the Internet Explorer via the object tag. Now, as you probably know, you can pass parameters to the activeX control by...
4
by: Don | last post by:
How do I retrieve URL parameters via html, where they were provided from a <form method=post...>? Thanks in advance, Don -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----...
0
by: crabbie_upk | last post by:
Hi All, I would like to know about redirecting along with POST parameters by doing which I can prevent users capturing the parametrs. Let me explain about my current scenario. 1. I have...
3
by: Joe Bloggs | last post by:
Does anyone know if its possible to pass parameters or the values of Request.QueryString from a web page to a custom control class? I'm using a C# Web Application. For Example I have Web Page1...
10
by: Adis | last post by:
Asp.Net Visual Studio 2003 SQL Server. Hi, Obtaining Data Based Upon Multiple Selections From a ListBox... I have database in Sqlserver and ListBox (Multiple Selection Mode) in my Visual...
6
by: Paolo Pignatelli | last post by:
I have an aspx code behind page that goes something like this in the HTML view: <asp:HyperLink id=HyperLink1 runat="server" NavigateUrl='<%#"mailto:" &amp;...
2
by: tshad | last post by:
When I normally set up my Sql statements and parameters, I would normally do: Dim objCmd as New SqlCommand("AddNewResumeCoverTemplate",objConn) objCmd.CommandType = CommandType.StoredProcedure...
0
by: Xah Lee | last post by:
In this article, i explain how the use of bit masks is a hack in many imperative languages. Often, a function will need to take many True/False parameters. For example, suppose i have a function...
3
by: computer_guy | last post by:
Hi Everyone, I run into a problem. I am trying to write an aspx that can dynamically generate an image based on some input parameters. Things are very simple if the size of the parameters is...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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
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...
0
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,...

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.