-1

Errors

Notice: Undefined index: nome in /storage/ssd5/324/8807324/public_html/autenticar.phpon line 3

Notice: Undefined index: email in /storage/ssd5/324/8807324/public_html/autenticar.phpon line 4

Notice: Undefined index: senha in /storage/ssd5/324/8807324/public_html/autenticar.phpon line 5

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /storage/ssd5/324/8807324/public_html/autenticar.php:9 Stack trace: #0 /storage/ssd5/324/8807324/public_html/index.php(2): require_once() #1 {main} thrown in /storage/ssd5/324/8807324/public_html/autenticar.phpon line 9

PHP

<?php 
// RECEBENDO OS DADOS PREENCHIDOS DO FORMUL�RIO !
$nome = $_POST ["nome"];    //atribui��o do campo "nome" vindo do formul�rio para variavel  
$email = $_POST ["email"];  //atribui��o do campo "email" vindo do formul�rio para variavel
$senha = $_POST ["senha"];  //atribui��o do campo "senha" vindo do formul�rio para variavel
//Gravando no banco de dados !

//conectando com o localhost - mysql
$conexao = mysql_connect("***","***","***");
if (!$conexao)
    die ("Erro de conexao com localhost, o seguinte erro ocorreu -> ".mysql_error());
//conectando com a tabela do banco de dados
$banco = mysql_select_db("tb_usu",$conexao);
if (!$banco)
    die ("Erro de conex�o com banco de dados, o seguinte erro ocorreu -> ".mysql_error());



$query = "INSERT INTO `tb_usu` ( `nome` , `email` , `senha` )
VALUES ('$nome', '$email', '$senha')";

mysql_query($query,$conexao);

echo "Seu cadastro foi realizado com sucesso!<br>Agradecemos a aten��o.";
?> 

Form

<div class="box" >
  <h2 id="txt-form" >Registro</h2>
  <i class="btn-close-form fas fa-times" ></i>
  <form method="post" action="autenticar.php" >

  <div>
  <input id="nome_usu"  name="nome_usu" type="name" required="" >
  <label>Nome</label>
  </div>

  <div>
  <input id="email_usu"  name="email_usu" type="email" required="" >
  <label>Email</label>
  </div>

  <div>
  <input id="senha_usu"  name="senha_usu" type="password" required="" maxlength="11"  >
  <label>Digite uma senha</label>
  </div>

  <input type="submit" value="Registrar" >

  <p class="txt-login" >já tem conta?</p>
  </form>
  </div>
brombeer
  • 8,206
  • 5
  • 21
  • 26
TheReyzer
  • 21
  • 6
  • 2
    `mysql_*` functions are deprecated, please use mysqli or pdo instead. And `type="name"` doesn't exist, should probably be `type="text"` – brombeer Feb 24 '19 at 18:30

1 Answers1

0

When you are posting your data your $_POST array keys must match the from the form that sends them.

for example, in your HTML the name of your email field is "email_usu", which means you would access it with

$_POST['email_usu'];

Also, be aware that inserting content directly into a database from user entry can be dangerous if it is not cared for properly. I encourage you to read the following about prepared statements and SQL injection.

http://php.net/manual/en/mysqli.prepare.php

MHewison
  • 814
  • 8
  • 16
  • if I put email_usu, nome_usu, senha_usu. the error only changes and adds the _usu – TheReyzer Feb 24 '19 at 17:55
  • Can you add var_dump($_POST); above your $_POST vars, see what output you get. – MHewison Feb 24 '19 at 18:00
  • more errors, i'm a beginner:( – TheReyzer Feb 24 '19 at 18:28
  • That's fine. There is no harm in trying to learn something new. var_dump($_POST); will show us the output from the form, but it will also show us the keys that were passed from the form. Do you have a copy of that output? – MHewison Feb 24 '19 at 18:31