login system using php and mysql

Asked

Viewed 175 times

-1

I’ve made some changes to the program, but it’s still giving me the slip...:

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');
}

?>
  • 2

    dar erro It is very generic, detail your problem better. See: http://answall.com/help/mcve

  • In addition to detail better, show the database.php. If something is wrong in it will influence your code too.

  • 1

    You must use mysqli_query($con, "SELECT ..."). The mysqli_query requires the first parameter to be the connection and the second to be the query.

  • I’m sorry confused but I still can’t work well with this site

  • @Inkeliz lol hadn’t seen your comment...

2 answers

3

It’s wrong that

$username = $_POST;
$pwd = $_POST

Correct is so

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

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

  • 1

    Probably this is the problem, but it is not possible to know if this is the solution. The last sentence is the most important, the index used in $_POST must be the same name used in name of their respective input.

1

mysqli_query() expects at least 2 Parameters, 1 Given.

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

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

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

Browser other questions tagged

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