0

I have a problem in my project that i cant fix yet. Im working with MySQL - PHP and everything is working OK but when I try to open "php/consult.php?consult=add" using the form below.

<form action="php/consult.php?consult=add" method="get">
        <td>Instruccion SQL:</td>
        <td>
        <input type="text" name="codecosult" required/>
        </td>
</form>

My browser doesn't change the URL to "php/consult.php?consult=add". Instead it shows only "php/consult.php", what have I done wrong? Thanks for your answers and your time, and sorry for my english (it isn't too good xD).

Kostas Mitsarakis
  • 4,772
  • 3
  • 23
  • 37

1 Answers1

0

This works if submitted - you don't need to add the query string - if it were an <a href="... then you would need the full query string for the url:

 <form action="php/test.htm" method="get">
         <td>Instruccion SQL:</td>
         <td>
         <input type="text" name="codecosult" required/>
         </td>
 <input type="submit" name="submit" value="Submit" />
 </form>

This gives me my url + /php/test.htm?codecosult=ghrth&submit=Submit

ghrth was what I had typed.

If you are submitting it with a script leave the query string off and let the "GET" method deal with it - script here is in the head.

<script language="javascript">function submit_this(){this.form.submit();}</script>

</head>
    <body>
         <form name="form" id="form" action="php/test.htm" method="GET">
                  <td>Instruccion SQL:</td>
                  <td>
                  <input type="text" name="codecosult" id="codecosult" required/>
                  </td>

         <div onClick="submit_this();">Submit</div> 

This gives me my url + test.htm?codecosult=dfthwrth

dfthwrth was what I had typed.

This also works, though the <a href="...'s hrefis modified here by the keypress event each time a key is pressed (may not work in all browsers):

 <input type="text" name="codecosult" onKeyPress="ahreff.href='php/test.htm?'+this.value;" required/>
 <a href="#" id="ahreff">Click Here</a>

This might be of interest - a dropdown will pass its value in the same way:

dropdown menu doesn't function - it will now!

Community
  • 1
  • 1
Steve
  • 808
  • 1
  • 9
  • 14