data insertion in mysqli with php

Asked

Viewed 130 times

1

Good morning guys, I’m having a problem inserting data in mysqli with php.

I am using a form with 3 fields: name, email and password. The problem is that the data I enter in the email field will stop the field and password and vice versa. And when it’s time to do the validation to give me trouble help me.

Here is the code:

public function registro(){
       $db = new Conexao();
       $sql = $db->query("SELECT nome,email FROM usuario WHERE nome='$this->nome' OR email='$this->email';");
       $existe = $db->recorrer($sql);

       if(strtolower($existe['nome'])!=strtolower($this->nome) and strtolower($existe['email'])!=strtolower($this->email)){
        $db->query("INSERT INTO usuario (nome,email,senha) VALUES('$this->nome','$this->email');");   
        session_start();
        $_SESSION['nome'] = $this->nome;
        header('location: Acesso.php');

       } else if(strtolower($existe['nome'])==strtolower($this->nome)){
          header('location: index.php?modo=registro&error=Usuario_usado');  
       }else if(strtolower($existe['email'])==strtolower($this->email)){
        header('location: index.php?modo=registro&error=Email_usado');   

       }
  }

form

<html>
    <head><title>Smart</title></head>
    <body>
     <h1>Registro</h1>   
     {if isset($error)}
          {$error}
         {/if}
     <form action="index.php?modo=registro"method="POST">
         <label>Nome</label><input type="text" name="nome"/><br/><br/>
         <label>Senha</label><input type="password" name="senha"/><br/><br/>
          <label>E-mail</label><input type="email" name="email"/><br/><br/>

<input type="hidden"name="registro" value="1"/>
         <input type="submit"value="Registrar-me"/>
 </form>
</body>
</html>

1 answer

3

INSERT INTO usuario (nome,email,senha) VALUES('$this->nome','$this->email');"

'thist->password' ??

Browser other questions tagged

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