Jump to content

How do I send data using an html link


jaisol99

Recommended Posts

Hi

 

If I have

<a href="main_file.php">

 

How do I send data to main_file.php

 

I have a group of links that are created on the fly and I want to give each link a value so that I can retrieve more info out of my database on individual items.

I don't realy want to use forms and buttons / tick boxes etc.

 

I'm looking for something like

<a href="main_file.php" VALUE = $_A_Variable>

So that I can identify which link was selected.

 

 

Link to comment
https://forums.phpfreaks.com/topic/178128-how-do-i-send-data-using-an-html-link/
Share on other sites

  • 3 years later...

Just to add to the above link. 

 

Use <?php session_start(); ?> before the <html> tags.  Read this somewhere online if you are using GET.

 

What I did is below, comment please. Totally and very unsecure.

 

So the first web page might be called 1stPage.php and you have a php variable that holds the information you want to pass to your second php page.

I called the variable $valueToPass.

 

<?php session_start(); // start session first for transfer of information ?>
<html><head><title>  </title></head><body>
<?php // start php
..... // code here
 echo '<a href="2ndPage.php?valuePassed='.$valueToPass.'">'. $valueToPass . '</a> ';
// so above is a hperlink with a php variable as the link text called $valueToPass.  It is what I processed in the 1st page and need to get to the 2nd
// page. I assigned the name valuePassed. 
... // more code
//end of php
?>
</body></html>
 
2nd page has:
$valRequested = $_GET['valuePassed'];
 
Worked for me. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.