Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

131
Visualizações
My html form automatically passing all field data in url

I have created a simple html form but I have encountered a weird problem which I have never seen before. When I click on submit then all of the data is directly passing to the URL bar. I don't know what is wrong with this can anyone help?

Form:


      <form id="form-data">
          Name<br><input type="text" name="name" id="name" value=""><br><br>
          Age<br><input type="number" name="number" id="age" value=""><br><br>
          Gender<br>
            <input type="radio" name="gender" value="Male">Male
            <input type="radio" name="gender" value="Female">Fe-male<br><br>
    
          <select name="country">
            <option value="Kashmir">Kashmir</option>
            <option value="Egypt">Egypt</option>
            <option value="Norway">Norway</option>
            <option value="Iceland">Iceland</option>
          </select><br>
          <br><input type="submit" id="submit" value="Save">
      </form>

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

the form uses get method therefore it displays the form values in the url. change the method to post to avoid this

method="post"

<!DOCTYPE html>
<html>
<head>
    <title></title>
<body>
  <form id="form-data" method="post">
      Name<br><input type="text" name="name" id="name" value=""><br><br>
      Age<br><input type="number" name="number" id="age" value=""><br><br>
      Gender<br>
        <input type="radio" name="gender" value="Male">Male
        <input type="radio" name="gender" value="Female">Fe-male<br><br>

      <select name="country">
        <option value="Kashmir">Kashmir</option>
        <option value="Egypt">Egypt</option>
        <option value="Norway">Norway</option>
        <option value="Iceland">Iceland</option>
      </select><br>
      <br><input type="submit" id="submit" value="Save">
  </form>

</body>
</html>

over 4 years ago · Santiago Trujillo Relatório

0

Add method attribute to your form tag like this:

<form action="welcome.php" method="post">

https://www.w3schools.com/tags/att_form_method.asp

over 4 years ago · Santiago Trujillo Relatório

0

If you don't send the data somewhere, it gets passed as URL parameters to the current page: From MDN Web Docs:

The action attribute defines where the data gets sent. Its value must be a valid relative or absolute URL. If this attribute isn't provided, the data will be sent to the URL of the page containing the form — the current page.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda