I am trying to print a user that is registered in my database as a test to implement it in some data later, I have a database with a user table where after filling out a form (user and password) they are sent to the same page php_self for which I use this conditional and print that user (entered in the form) and compared in the db, but I do not throw the result, and probe with return and with this way
if ($_SERVER['REQUEST_METHOD']=='POST') {
$usuariodb = $_POST['usuario'];
$conexion_usr = new PDO('mysql:host=localhost;dbname=ws_blog;charset=UTF8','root','');
$sql = "SELECT * FROM user_blog WHERE name ='".strtolower($usuariodb)."'";
$result = $conexion_usr->query($sql);
$usr_name = $result->fetchAll();
foreach ($usr_name as $names) {
echo $names;
}
}
and this one
if ($_SERVER['REQUEST_METHOD']=='POST') {
$usuariodb = $_POST['usuario'];
$conexion_usr = new PDO('mysql:host=localhost;dbname=ws_blog;charset=UTF8','root','');
$sql = "SELECT * FROM user_blog WHERE name ='".strtolower($usuariodb)."'";
$result = $conexion_usr->query($sql);
return $result
}
}