Klapsius
Klapsius

Reputation: 3359

Passing data to another php file using GET method

I know how to pass data to another page with Get method as hiperlink:

{echo "<a  href=file.php?variable1=".$row['value1']."&variable2=".$row['value2']."'>Confirm</a>"; }

How add value from input field in this lane above? Is it possible?

<input name="field_name"  type="text" >

Upvotes: 1

Views: 224

Answers (4)

Eduard
Eduard

Reputation: 3576

{echo "<a  href=file.php?variable1=".$row['field_name']."&variable2=".$row['field_name_etc']."'>Confirm</a>"; }

Upvotes: 0

VCNinc
VCNinc

Reputation: 757

Depending on the value of the method attribute in your form, the input's value would be passed to PHP via either the $_POST or the $_GET array. You can link this to PHP via the following code:

{echo "<a  href=file.php?variable1=".$_GET['field_name']."&variable2=".$row['value2']."'>Confirm</a>"; }

Please note that the form should be submitted first before this code is executed. If this is not desirable, you should probably use JavaScript.

Upvotes: 1

MarcoS
MarcoS

Reputation: 17711

Try this way:

{echo "<a  href=file.php?variable1=".$row['value1']."&variable2=".$row['value2']."&field_name=".$_GET['field_name']."'>Confirm</a>"; }

Upvotes: 1

Bhavya Shaktawat
Bhavya Shaktawat

Reputation: 2512

In this case use $_GET['field_name'] in your php code to add value of the input field

For eg:

<input name="field_name1"  type="text" >
<input name="field_name2"  type="text" >

{echo "<a  href=file.php?variable1=".$_GET['field_name1']."&variable2=".$_GET['field_name2']."'>Confirm</a>"; }

Upvotes: 1

Related Questions