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
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. 
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.