Jump to content

Submit an input through a <a href=''></a> Link


keepAway

Recommended Posts

This is a basic example of what i`m trying... and work`s fine..

<form name='validate' action='#'>
  <input type='text' name='firstinput' />
  <input type='text' name='secondinput' />
  <input type='submit' name='input' value='Add' />
</form>

<?php
if(isset($_GET['input'])) 
  {
  echo $_GET['firstinput']." - ".$_GET['secondinput'];
  }
?>

 

 

but i want to submit this inputs on this way..

 

<form name='validate' action='test.php'>
  <input type='text' name='firstinput' />
  <input type='text' name='secondinput' />
<a href='test.php?input=ok'>Add</a><br />  
</form>

<?php
if(isset($_GET['input']) && $_GET['input'] == "ok") 
  {
  echo $_GET['firstinput']." - ".$_GET['secondinput'];
  }
?>

 

i`m pretty new in this language and i`m doing my best to learn it, so is there any chance to make him work?

Link to comment
https://forums.phpfreaks.com/topic/239155-submit-an-input-through-a-link/
Share on other sites

Why do you want to submit a form using a link and not a button?

 

Here's doing it with a link

 

<form name='validate' action='test.php?input=ok' method='post' id='myform'>
  <input type='text' name='firstinput' />
  <input type='text' name='secondinput' />
<a href='javascript: document.forms["myform"].submit();'>Add</a><br />  
</form>

 

You then have to use

 

<?php
if(isset($['input']) && $_GET['input'] == "ok") 
  {
  echo $_POST['firstinput']." - ".$_POST['secondinput'];
  }
?>

 

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.