How do I connect php to the database of this registry?

Asked

Viewed 62 times

0

inserir a descrição da imagem aqui

The registration code is this:

 <form class="register-form">
    <input type="text" placeholder="nome"/>
    <input type="password" placeholder="senha"/>
    <input type="text" placeholder="email"/>
    <button>create</button>
    <p class="message">Already registered? <a href="cadastrando.php">Sign In</a></p>
  </form>
  <form class="login-form">
    <input type="text" placeholder="username"/>
    <input type="password" placeholder="password"/>
    <button>login</button>
    <p class="message">Not registered? <a href="#">Create an account</a></p>
  </form>

I’ve tried connecting to the database using this command:

<html>

<head>
<title>Cadastrando...</title>
</head>

<body>
<?php
$host = "localhost";
$user = "root";
$pass = "xampp";
$banco = "cadastro";
$conexao = mysql_connect($host, $user, $pass) or die(mysql_errir());
mysql_select_db($banco) or die(mysql_error());
?>

<?php

$nome=$_POST['nome'];
$senha=$_POST['senha'];
$email=$_POST['email'];
$sql = mysql_query("INSERT INTO usuarios(nome, senha, email)
VALUES('$nome', '$senha', '$email')");
?>

</body>
</html>

Being that I created the database every straight q n works out. Can someone help me?

  • 2

    Already got the functions wrong mysql_ should not be used, use Mysqli or PDO for connection to the bank.

1 answer

2

You have to send this form to a page to process the data, make the query to the database and then establish the registration.

<form action="cadastro.php" name="meuForm" method="POST">
...seu form....
</form>

PHP page - php. On this page, you have to save the data of the fields completed by the user and then query the database.

You can consult this information:
http://www.phpgang.com/how-to-create-login-and-signup-form-in-php_377.html

Browser other questions tagged

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