0
I’m trying to connect to the database via myqli
with php
but I’m not getting it. Follow the code:
<html>
<head>
<title>sistema de cadastro</title>
</head>
<body>
<form method="get" action="cadastramento.php">
nome:
<input type="text" name="name" />
<p></p>
sobre nome:
<input type="text" name="sobrenome" />
<p></p>
senha:
<input type="password" name="senha" />
<p></p>
<input type="submit" value="" />
</form>
</body>
</html>
Now the connection code mysqli in php:
<html>
<head>
<title> cadastramento</title>
</head>
<body>
<?php
$servidor = 'localhost';
$usuario = 'root';
$senha = '';
$banco = 'mydb';
$mysqli = new mysqli($servidor, $nome, $ssobrenome, $senha);
if (mysqli_connect_errno()) trigger_error(mysqli_connect_error());
?>
<?php
$mysqli = new mysqli('localhost', 'root', '', 'mydb');
$sql = "SELECT `id`, `titulo` FROM `cadastramento` LIMIT 5";
$query = $mysqli->query($sql);
while ($dados = $query->mysqli_fetch_array()) {
echo 'ID: ' . $dados['id'] . '';
echo 'Título: ' . $dados['titulo'] . '';
}
echo 'Registros encontrados: ' . $query->num_rows;
?>
Define your question better, help the answers, at first I understood about connecting the bank. and follow answer.
– Thalles Daniel
You need to provide more details: some error occurs or nothing happens?
– user28595
You will not pass a password by
get
The.o– rray