I created a registration system using PHP+Mysql then when running asks to replace Mysql with Mysqli... Which ones should I replace?

Asked

Viewed 469 times

0

<?php
$host = "localhost";
$user = "root";
$pass = ""; 
$banco = "dbcadastro";
$conexao = mysql_connect($host, $user, $pass) or die (mysql_error());
mysql_select_db($banco) or die (mysql_error());
//mysql_connect_banco($host, $user, $pass);
?>

<?php
$nome = $_POST['nome'];
$sobrenome = $_POST['sobrenome'];
$pais = $_POST['pais'];
$estado = $_POST['estado'];
$cidade = $_POST['cidade'];
$email = $_POST['email'];
$senha = $_POST['senha'];
$sql = mysql_query("INSERT INTO usuarios(nome, sobrenome, pais, estado, cidade, email, senha)
 VALUES ('$nome', '$sobrenome', '$pais', '$estado', '$cidade', '$email', '$senha',)");
?>
  • 1

    All functions mysql_* are deprecated, you must replace all calls to these functions.

1 answer

2


<?php
$host = "localhost";
$user = "root";
$pass = ""; 
$banco = "dbcadastro";
$conexao = mysqli_connect($host,$user,$pass,$banco);
// verifica a conexao
if (mysqli_connect_errno())
  {
  echo "Erro ao conectar: " . mysqli_connect_error();
  }
?>

<?php

if (isset($_POST["submit"])) {
    $nome = $_POST['nome'];
    $sobrenome = $_POST['sobrenome'];
    $pais = $_POST['pais'];
    $estado = $_POST['estado'];
    $cidade = $_POST['cidade'];
    $email = $_POST['email'];
    $senha = $_POST['senha'];
    $sql = mysqli_query($conexao,"INSERT INTO usuarios(nome, sobrenome, pais, estado, cidade, email, senha");
}
?>
  • Much of the code worked. More ta accusing error in $name = $_POST['name']; $last name = $_POST['last name']; $parents = $_POST['parents']; $status = $_POST['status']; $city = $_POST['city']; $email = $_POST['email']; $password = $_POST['password']; &#Notice: Fined index: in C: wamp www registered.php on line 23

  • updated the answer. test now

  • 1

    Thank you very much! Helped a lot now just insert the data into the table :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.