$('#type'). val('juridica');

Asked

Viewed 84 times

0

I am having a big problem in receiving and sending the data to the database because, when creating a system where there is the possibility of using the physical person or legal person, they send to the same php page using the get mode I can show better how it looks (I always use the mothod post)..

localhost/php/action_cadastro.php?tipo=fisica&txtNome=elizandro+rafael+schmidt&txtEndereco=sanntos+dumont&txtBairro=lolo&txtCidade=louco&txtUf=SC&txtCep=02210-202&txtEmail=elizandro159%40gmail.com&txtTelefone=%2802%29+9390-3000&txtCelular=&txtRazaoSocial=&txtCnpj=&txtNomeFantasia=&txtEndereco2=&txtBairro2=&txtCidade2=&txtUf2=SC&txtCep2=&txtEmail2=&txtTelefone2=&txtFax2=&txtCelular2=&txtSite=&login=&senha=&senha2=

**

But the problem is that I don’t know how to create the condition where I can read the physical or legal type, I tried that way:

$tipo= $_post['tipo'];
if($tipo==="juridica"){ tantmatnantant
}else{
if($tipo==="fisica"){blablablablabla
}

but when storing in this way it goes null to the database, which is properly connected taking all the variables of physics. (detail used the same table to avoid bother on login)

   $query = " INTO usuario (tipo,Nome,Endereco,Bairro,Cidade,Uf,Cep,Email,Telefone,Celular,Razao,Cnpj,Fantasia,Endereco2,Bairro2,Cidade2,Uf2,Cep2,Email2,Tel2,Fax2,Celular2,site,login,senha,data,hora)
         VALUES ('$tipo','$Nome','$Endereco','$Bairro','$Cidade','$Uf','$Cep','$Email','$Telefone','$Celular','$Razao','$Cnpj','$Fantasia','$Endereco2','$Bairro2','$Cidade2','$Uf2','$Cep2','$Email2','$Tel2','$Fax2','$Celular2','$site','$login','$senha','$data','$hora')"or die ("1337");
          $insert = mysql_query ($query,$conexao); 

  • But use the POST method, and do the separation, if($_POST[person type]=physical) $tp = physical Else $tp = legal..

  • I always use the post method only to show I used get, but I will try friend, let’s see if it works. I already answer if I can.

  • Okay, no problem, just let me know.

  • It didn’t work buddy... @.@ (I can’t touch which bug @.@ )kkk

  • I left an answer that might solve your problem :)

1 answer

0


In your example you use the GET method to submit the form and take the return with POST. When submitting the form using GET take the return with $_GET, if sending using POST take the return with $_POST.

Note that the php variable $_POST is case sensitive, then $_POST is different from $_post. In your code you use both cases. Change all to $_POST (capital letter).

I hope I’ve helped :)

  • Thanks friend Voce helped me ... good had already overcome this problem but, thank you very much because, would hardly realize this mistake alone...

  • :) Thanks! That was the problem?

  • yes friend, it was one of the last variables _post that I entered in the code , not checking bind from Capslock... thanks for the help..

Browser other questions tagged

You are not signed in. Login or sign up in order to post.