0

I have to tables in my database: Parking and Manager. This to tables have the IDmanager.

The user made a login with some IDmanager.

Than, i need to compare the IDmanager of the loged user with the parking IDmanager in a query to print the name of the parking.

My code is in portuguese, because the is a portuguese project.

This is my login code:

How can i made the query? Because, the output is nothing.

<?php
  session_start();
  require 'Config_log.php';
  require 'mylibrary.php';
  if (isset($_POST['submit'])) {

    $error = $_REQUEST['uname'];

    if (empty($error)) {
        print "Name is empty";
    } else {
        $error = $_REQUEST['upass'];
        if (empty($error)) {
        print "Password is empty";
        }
    }

    $uname = $_REQUEST['uname'];
    echo $uname;

    $pass = $_REQUEST['upass'];
    echo $pass;


    $result = $conn->query("SELECT * FROM `gestor` WHERE `USERNAMEGESTOR` = '$uname' and `PASSWORDGESTOR` = '$pass' ");

    if( ($result->num_rows) > 0)
    {
        $_SESSION['login'] = $uname;
        $_SESSION['password'] = $pass;
        //$_SESSION['nome'] = $_REQUEST['name'];
        header("Location: main.php");
    }else{
        echo "incorrect login";
    }
}
?>

Than, in this page, i want to compare and print the name of the parking:

<div class="col s9" id="ajaxContent">
            <div class="center-align Nome-parque">
                <?php
                require 'Config_log.php';
                $sql = "SELECT NOMEPARQUE FROM parque WHERE IDGESTOR= '".$logado."'";
                $result = $conn->query($sql);
                $row = $result->fetch_assoc();
                    echo $row['NOMEPARQUE']."<br>";
                 ?>
            </div>
  • NEVER put $_POST/$_GET/$_REQUEST data directly into a query, it can be very harmful if someone seeks to exploit your mistake – Oleks Dec 02 '16 at 22:59
  • check your [php error log](http://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display) – WEBjuju Dec 02 '16 at 22:59

0 Answers0