Jump to content

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


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

if i`m not using a submit input will return an undefined index ...

 

Notice: Undefined index: firstinput in C:\xampp\htdocs\targovisteni\admin\test.php on line 14

Notice: Undefined index: secondinput in C:\xampp\htdocs\targovisteni\admin\test.php on line 14

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'];
  }
?>

 

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.