-1
my system has to do a search, using a patient’s Cpf, then when he type his Cpf, have to have a search in the bank, where php will get all the information that the patient has with that Cpf that he typed (that is, he already has a register, with name, Cpf, age, gender and etc...) and bring everything in the inputs corresponding to the html page, the same page that he used to register, but will be a kind of clone of her.
the code of consultation
<h2>Consultar Ficha do Paciente</h2>
<div>
<input class="campo-form" type="text" name="cpf" placeholder="CPF" maxlength="14"></br>
</div>
<div class="groupb">
<button class="botao" type="submit">Buscar</button>
</div>
<div class="groupb">
<a href="php/menuNutricionista.php" class="botoes">Voltar</a>
</div>
</form>
the php code
<?php include("conexao.php"); $pdo=conectar(); $cpf = $_POST['cpf']; $consulta= $pdo->prepare("SELECT cpf FROM paciente where cpf = $cpf"); ?>
I’m having doubts about this code, it’s probably wrong and some lines are missing. wanted someone to explain me how to make a correct query structure in PDO.
Thanks for your attention, I just can’t understand how I’m going to play this in the inputs. may seem like a stupid question and because I’m not able to understand it very well. but I did what you passed me and I saw that it returned only Cpf.
– Bruno D.assis
I made one more attempt here and now giving the error: Notice: Trying to get Property of non-object in C: wamp64 www test query.php on line 40 Call Stack #Timememoryfunctionlocation 10.0012243384{main}( )... query.php:0 "
– Bruno D.assis
in the input that should appear the information, ta appearing that <br /><font size='1'><table class='Xdebug-error Xe-notice' dir='Ltr' border='1' cellspacing='0' cellpadding='1'><tr><th align='left' bgcolor='#f57900' colspan=
– Bruno D.assis
do so @Brunod.Assis there at print_r($result) show the exit please
– Anderson Henrique
Array ( [0] => Array ( [Cpf] => 111.111.111-11 [0] => 111.111.111-11 ) ) and this is what print_r($result) returns.
– Bruno D.assis
So @Brunod.Ssis for example if you want to show his Cpf in the Cpf field just do it look like this <div> <input class="field-form" id="Cpf" type="text" name="Cpf" placeholder="CPF" maxlength="14" value="<? php echo $result[0]['Cpf'];? >"><br> </div> If you want to show name and email and such you need to change your query, because it only filters Cpf you can do the query "SELECT * FROM patient Where Cpf = $Cpf"
– Anderson Henrique
got it, in the case here I have are 39 fields. I would have to do <?php echo $result[0]['field'];? > in each value and that? example: <?php echo $result[1]['name'];? >, <?php echo $result[2]['email'];? > and etc?
– Bruno D.assis
Yes, it would have @Brunod.
– Anderson Henrique