-1
I’m trying to do a function to search by student’s name in the databank.
I’m having the following mistake:
Notice: Undefined index: filter in C: meuphp test search_student.php on line 7
<?php
require 'conexao.php';
include 'classe_aluno.php';
$exibindo= new Aluno($mysql);
$filtrado=$exibindo->exibirUm($_POST['filtro']);?>
The line showing the error is:
$filtrado=$exibindo->exibirUm($_POST['filtro']);?>
The second mistake is
Fatal error: Uncaught TypeError: Argument 1 passed to Aluno::exibirUm() must be of the type string, null given, called in C:\meuphp\teste\pesquisa_aluno.php on line 7 and defined in C:\meuphp\teste\classe_aluno.php:29 Stack trace: #0 C:\meuphp\teste\pesquisa_aluno.php(7)Student->displayUm(NULL) #1 {main} thrown
public function exibirUm(string $filtro){
$exibir=$this->mysql->prepare("SELECT * FROM aluno WHERE nome LIKE ?");
$exibir->bind_param('s',$filtro);
$exibir->execute();
$filtrado=$exibir->get_result()->fetch_assoc();
return $filtrado;
}
This answers your question? Undefined Index while recovering data from POST
– tvdias