I cannot understand/find the error in php code

Asked

Viewed 40 times

-2

I am creating a client registration system and when I run . php it simply appears this error:

inserir a descrição da imagem aqui

php code:

<?php

      $login = $_POST['inputEmail'];
      $senha = MD5($_POST['inputSenha']);
      $connect = mysql_connect('localhost','postgres','root');
      $db = mysql_select_db('SrVisao');
      $query_select = "SELECT inputEmail FROM usuarios WHERE inputEmail = '$inputEmail'";
      $select = mysql_query($query_select,$connect);
      $array = mysql_fetch_array($select);
      $logarray = $array['inputEmail'];

      if($inputEmail == "" || $inputEmail == null){
        echo"<script language='javascript' type='text/javascript'>
        alert('O campo email deve ser preenchido');window.location.href='
        cadastroCliente3.html';</script>";

      }else{
        if($logarray == $inputEmail){

          echo"<script language='javascript' type='text/javascript'>
          alert('Esse login já existe');window.location.href='
          cadastroCliente3.html';</script>";
          die();
        }else{
          $query = "INSERT INTO usuarios (inputEmail,inputSenha) VALUES ('$inputEmail','$inputSenha')";
          $insert = mysql_query($query,$connect);

          if($insert){
            echo"<script language='javascript' type='text/javascript'>
            alert('Usuário cadastrado com sucesso!');window.location.
            href='login.html'</script>";
          }else{
            echo"<script language='javascript' type='text/javascript'>
            alert('Não foi possível cadastrar esse usuário');window.location
            .href='cadastroCliente3.html'</script>";
          }
        }
      }
    ?>
  • I think you should use mysqli_connect() instead of mysql_connect() see the difference: https://answall.com/questions/63331/dif%C3%A7a-entre-as-fun%C3%A7%C3%B5es-mysql-connect-e-mysqli-connect-em-php

1 answer

1

The first two messages are notifications that PHP did not find the indexes reported within $_POST (see that answer for more information). You should check whether this information is being passed correctly.

Regarding the last two messages, it is because you are calling a function that has been discontinued in PHP. See that answer for more details.

Browser other questions tagged

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