html - PHP doesn't connect with MySQL -


this code supposed information simple html form , post in mysql database:

<html>    <head>  <title>cadastro de cinema</title>  <head>    <body>  <?php  $host = "localhost";  $user = "root";  $pass = "";  $banco = "cinema";  $con = @mysqli_connect($host, $user, $pass, $db) or die(mysql_error());    ?>    <?php    $email= isset($_post['email']) ? $_post['email'] : '';  $senha= isset($_post['senha']) ? $_post['senha'] : '';  $nome= isset($_post['nome']) ? $_post['nome'] : '';  $rua= isset($_post['rua']) ? $_post['rua'] : '';  $bairro= isset($_post['bairro']) ? $_post['bairro'] : '';  $numero= isset($_post['numero']) ? $_post['numero'] : '';  $cidade= isset($_post['cidade']) ? $_post['cidade'] : '';  $sql = mysqli_query($con, "insert cinema(email, senha, nome, rua, bairro, numero, cidade)  values ('$email', '$senha', '$nome', '$rua', '$bairro', '$numero', '$cidade')");    echo "ok";  ?>  </body>    </html>

when test it, "ok" echo, info not in mysql database. be?

it better if submit database here. so, can check if table/data type supported query or not. please try this:

<html>  <head> <title>cadastro de cinema</title> <head>  <body> <?php $host = "localhost"; $user = "root"; $pass = ""; $banco = "cinema"; $con = @mysqli_connect($host, $user, $pass, $banco) or die("could not connect database. " . mysqli_connect_error()); ?>  <?php  $email= isset($_post['email']) ? $_post['email'] : ''; $senha= isset($_post['senha']) ? $_post['senha'] : ''; $nome= isset($_post['nome']) ? $_post['nome'] : ''; $rua= isset($_post['rua']) ? $_post['rua'] : ''; $bairro= isset($_post['bairro']) ? $_post['bairro'] : ''; $numero= isset($_post['numero']) ? $_post['numero'] : ''; $cidade= isset($_post['cidade']) ? $_post['cidade'] : ''; $sql = mysqli_query($con, "insert cinema(email, senha, nome, rua, bairro, numero, cidade) values ('$email', '$senha', '$nome', '$rua', '$bairro', '$numero', '$cidade')");  echo "ok"; ?> </body>  </html> 

simple database table used:

create table `cinema` (   `email` varchar(50) not null,   `senha` varchar(50) not null,   `nome` varchar(50) not null,   `rua` varchar(50) not null,   `bairro` varchar(50) not null,   `numero` varchar(50) not null,   `cidade` varchar(50) not null ) engine=innodb default charset=latin1; 

thank you


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -