I've made a HTML file containing only a form with a textbox and a submit button.
The form calls a php that will check if the text from the textbox represents a register in the database.
Html file:
<form action="index.php" method="post">
<input type="text" name="nome"/>
<input type="submit" value="Rodar"/>
</form>
PHP file:
<?php
$nome = $_POST['nome'];
$pdo = new PDO('mysql:host=myhost;dbname=mydb', 'user', 'pw');
if ($pdo->query("SELECT * from renatinho where nome='".$nome."'")->fetchColumn() > 0){
foreach($pdo->query("SELECT * from renatinho where nome='".$nome."'") as $row) {
echo $row['id'] . $row['nome'];
}
$pdo = null;
}
else{
echo "Não há ninguém com esse nome.";
}
?>
The thing is: when I press the button it calls and displays the php file. The php file has no layout. I want the results to be displayed in the HTML file, cause i don't want to make a whole new page just to display the values.
I want the results to be in the same page where the form is.
I've being googling it for 2 days, but I don't know what exactly to search. All the results I got are tutorials that displays the php file, and that's what I'm doing now but that's not what I want.