login system using php and mysql [duplicate]

-1

I made changes to the program but it still gives me error ... it says the following:

  

mysqli_query () expects at least 2 parameters, 1 given.

<?php
$username="username";
$pwd="pwd";
include ("database.php");
session_start();
    /*nesta linha----->*/ $res= mysqli_query("select username, pwd from user where username='$username' and pwd='$pwd'") or die(mysql_error());
    if(mysql_num_rows($res)==0)
    {
        $res['username'] = $username;
        $res['pwd'] = $pwd;
        header('PaginaIniciaDoutora1.php');

    }
else{
    unset ($_SESSION['username']);
    unset ($_SESSION['pwd']);
    header('Pagina.php');
}

?>
    
asked by anonymous 21.01.2017 / 23:02

2 answers

3

This is wrong

$username = $_POST;
$pwd = $_POST

Correct is like this

$username = $_POST[user];
$pwd = $_POST[pwd];

This use and pwd comes from the form html in input name='user' and input name='pwd' .

    
21.01.2017 / 23:19
1
  

mysqli_query () expects at least 2 parameters, 1 given.

Wait 2 parameters, that is, the link and the query.

Then mysqli_query($con, $query) ...

Where $con is the connection variable and $query , your query ...

    
22.01.2017 / 01:48