keepAway Posted June 12, 2011 Share Posted June 12, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/239155-submit-an-input-through-a-link/ Share on other sites More sharing options...
xyph Posted June 12, 2011 Share Posted June 12, 2011 <form action='test.php?input=ok' method='get'> Should do the same thing Quote Link to comment https://forums.phpfreaks.com/topic/239155-submit-an-input-through-a-link/#findComment-1228749 Share on other sites More sharing options...
keepAway Posted June 12, 2011 Author Share Posted June 12, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/239155-submit-an-input-through-a-link/#findComment-1228757 Share on other sites More sharing options...
xyph Posted June 12, 2011 Share Posted June 12, 2011 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']; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/239155-submit-an-input-through-a-link/#findComment-1228772 Share on other sites More sharing options...
keepAway Posted June 12, 2011 Author Share Posted June 12, 2011 it`s working, thanks.. As i told you, i`m pretty new in this language. I have a long link and using a button will redirect me out of the page after is submited... this is my explanation. Once again, thank you. Quote Link to comment https://forums.phpfreaks.com/topic/239155-submit-an-input-through-a-link/#findComment-1228778 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.