1
I created a form and I’m trying to get the data of a radio button, and an input, but I’m not able to access them via POST in php or the javascript in which I’m using a function to disable the fields
Html
<form name="cdUsuario" class="cadastroUsuario" type="submit">
<div class="row">
<div class="input-field col s12 l6">
<i class="mdi-action-account-circle prefix"></i>
<input id="nome" name="nome" value="<?php echo $result['nm_nome'] ?>" type="text" disabled>
<label for="nome">Primeiro Nome</label>
</div>
<div class="input-field col s12 l6">
<input id="sobrenome" required name="sobrenome" value="<?php echo $result['nm_sobrenome'] ?>" type="text" disabled="disabled">
<label for="sobrenome">Sobrenome</label>
</div>
</div>
<div class="row">
<div class="input-field col s12 l6">
<i class="mdi-communication-email prefix"></i>
<input id="email" required name="email_altera" type="email" class="validate" value="<?php echo $result['nm_email'] ?>" disabled="disabled">
<label for="icon_email" data-error="Incorreto" data-success="Válido">E-mail</label>
</div>
<div class="input-field col s12 l6">
<p>
<input required name="Cd_sexo" value="Masculino" type="radio" id="rd_masculino" <?php echo $Result_sexoM ?> disabled="disabled"/>
<label for="rd_masculino">Masculino</label>
<input required name="Cd_sexo" type="radio" value="Feminino" id="rd_feminino" <?php echo $Result_sexoF ?> disabled="disabled"/>
<label for="rd_feminino">Feminino</label>
</p>
</div>
</div>
<div class="row">
<div class="input-field col s12 l6">
<!-- Máximo de 11 caracteres, o suficiente para um número padrão DDD + número, exemplo: 13991636095 -->
<i class="mdi-communication-call prefix"></i>
<input id="telefone" name="telefone" type="text" value="<?php echo $result['cd_telefone_fixo'] ?>" maxlength="11" disabled="disabled"> <!-- minlength="11" -->
<label for="telefone">Telefone</label>
</div>
<div class="input-field col s12 l6">
<i class="mdi-hardware-phone-iphone prefix"></i>
<input id="celular" required name="celular" type="text" value="<?php echo $result['cd_telefone_movel'] ?>" maxlength="11"disabled="disabled">
<label for="senha">Telefone Celular</label>
</div>
<div class="input-field col s12 l6">
<i class="mdi-action-https prefix"></i>
<input id="senha" required name="senhaEdita" type="password" value="<?php echo $result['cd_senha'] ?>" class="validate" disabled="disabled">
<label for="senha">Senha de Acesso</label>
</div>
<div class="input-field col s12 16">
<input type="checkbox" id="perfilprofissional" name="boxProfissional"
onclick="Mudarestado('formProfissional')">
<label for="perfilprofissional">Perfil Profissional</label>
</div>
<div class="row" id ="formProfissional" name="fmProfi" style="display: none;">
<div class="input-field col s12 l6">
<select class = "browser-default">
<option value = "" disabled selected>Área de Atuação</option>
<option value = "1">Informática</option>
<option value = "2">Aparelhos Eletrônicos e Eletrodomésticos</option>
<option value = "3">Aulas</option>
<option value = "4">Autos</option>
<option value = "5">Consultoria</option>
<option value = "6">Eventos</option>
<option value = "7">Moda e Beleza</option>
<option value = "8">Reformas e Serviços Gerais</option>
<option value = "9">Saúde</option>
<option value = "10">Serviços Domésticos</option>
<option value = "11">Comércio</option>
<option value = "12">Esportes e Lazer</option>
</select>
</div>
<div class="input-field col s12 l6">
<i class="mdi-action-wallet-travel prefix"></i>
<input id="email" type="email" name="Ped_email">
<label for="icon_email" data-error="Incorreto" data-success="Válido">Formação</label>
</div>
<!-- TextArea Observações do meu perfil profissional -->
<div class="row">
<div class="input-field col s12 16">
<textarea id="textarea2" class="materialize-textarea" data-length="120"></textarea>
<label for="textarea2">Observações</label>
</div>
</div>
</div>
<!-- <a href="javascript:void(0);">Meus anúncios</a></label>
<a href="javascript:void(0);">Meus pedidos</a></label> -->
</div>
<button type="submit" class="btn blue center-align" name="Salvar" id="SalvarDados" >Salvar
</button>
<button class="btn blue center-align" name="Editar" id="EditarDados">Editar Dados
</button>
<!-- Loader AJAX -->
<font color="red"<p><center><h7 class="emailCadastrado"></h7></center></p></font>
<font color="green"<p><center><h7 class="sucessoCadastro"></h7></center></p></font>
</div>
</div>
</div>
</form>
javascript
<script>
$(document).ready(function() {
$("#EditarDados").click(function (event) {
event.preventDefault();
$("#nome").prop("disabled", false);
$("#sobrenome").prop("disabled", false);
$("#email").prop("disabled", false);
$("#Cd_sexo").prop("disabled", false);
$("#telefone").prop("disabled", false);
$("#celular").prop("disabled", false);
$("#senhaEdita").prop("disabled", false);
});
});
</script>
php
include_once("usuario_class.php");
$nome=$_POST['nome'];
$sobrenome=$_POST['sobrenome'];
$telefone_fixo=$_POST['telefone'];
$telefone_movel=$_POST['celular'];
$email=$_POST['email_altera'];
$sexo=$_POST['Cd_sexo'];
$senha=$_POST['senha'];
php’s return message is as follows: Undefined index in Cd_sex
You only posted part of the code. Where is the rest of the code referring to name, surname etc...?
– user60252
updated friend
– Reignomo
They are not posted because they are disabled. And its js code to take the disableds tries to reference the inputs by an id that does not match what is in html
– bfavaretto
Get it wrong, man
– Reignomo