error Undefined index in php

0

in php, I get this error

  

Notice: Undefined index: user in C: \ xampp \ htdocs \ exemplification \ consultusuario.php on line 4

first php

<!--   consultarUsuario.php-->

<?php
include('functions.php'); 
$user=$_GET['user'];                       /* linea 4*/
if ($resultset = getSQLResultSet("SELECT contra FROM 'usuarios' WHERE usuario='$user'")) {

        while ($row = $resultset->fetch_array(MYSQLI_NUM)) {
        echo json_encode($row);


        }

   }

?>

second php ##

<!-- functions.php -->
<?php 
header( 'Content-Type: text/html;charset=utf-8' );


function ejecutarSQLCommand($commando){

  $mysqli = new mysqli("localhost", "root", "", "ejemplologin");

/* check connection */
if ($mysqli->connect_error) {
    printf("Connect failed: %s\n", $mysqli->connect_error);
echo li;
    exit();
}

if ( $mysqli->multi_query($commando)) {
     if ($resultset = $mysqli->store_result()) {
        while ($row = $resultset->fetch_array(MYSQLI_BOTH)) {
echo listo;

        }
        $resultset->free();
     }


}



$mysqli->close();
}

function getSQLResultSet($commando){


  $mysqli = new mysqli("localhost", "root", "", "ejemplologin");

/* check connection */
if ($mysqli->connect_errno) {
    printf("Connect failed: %s\n", $mysqli->connect_error);
    exit();
}

if ( $mysqli->multi_query($commando)) {
    return $mysqli->store_result();




}



$mysqli->close();
}


?>
    
asked by Ayrton Axel 14.11.2017 в 16:25
source

1 answer

3

The problem is that the variable is not defined. Which is solved in the following way.

$user = isset($_GET['user']) ? $_GET['user'] : '';

Once this is done, the problem will be in the query, because apparently the variable by GET is never sent to the page.

Which should have this format consultarUsuario.php?user=juan or via ajax with the verb GET

Greetings

    
answered by 14.11.2017 в 16:33