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

274
Visualizações
php returns undefined array key when I POST radio buttons

I have this html code:

    <form method="POST" action="location/files/myscript.php">
      <input type="radio" name="choice" value="ex1">
      <input type="radio" name="choice" value="ex2">
      <button type="button" id="print">
    </form>

I know there is no submit button, but I send a request with ajax like this:

$('#print').on('click', () => {
request = $.ajax({
            url: "location/files/myscript.php",
            type: "POST",
            data: dataD
        });
}

And my php file looks like this:

$choice = $_POST['choice'];

if($choice == 'ex1') {
   echo "yes";
} else {
   echo "no";
}

I tried with isset and empty too, but I still get Undefined array key "choice"

EDIT: no, I don't want the warning just to disappear. The problem is that I select a radio button and it is still returning that warning. I want it to work, not no hide the warning

about 4 years ago · Juan Pablo Isaza
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