Sunday, 25 August 2013

MySQL + PHP 1 Input Login

MySQL + PHP 1 Input Login

I am trying to make 1 Password-Login. For example, when user enters code,
his page appears. I have a table, 2 strings in my database.

Strings:
sifre (it is password)
bizimkey (it is userpage)


My Code is like this:

Index.html (Just important part, please don't talk about html, body etc.
tags):

<form action="key.php" method="POST">
<input type="password" id=yaz name="pass" maxlength="30" value="">
<input type="submit" value=" " id="login" style="margin-bottom:10px;">
</form>
key.php:

<? ob_start(); ?>
<html>
<?php
$host = "localhost";
$user = "username";
$password = "password";
$database = "database";
$con = mysqli_connect($host,$user,$password,$database);
// Check connection
if (mysqli_connect_errno())
{
echo "ERROR!";
}
$result = mysqli_query($con,"SELECT * FROM keyler");
if ($_POST['pass'] == $row['sifre'])
{
while($row = mysqli_fetch_array($result))
{
echo $row['bizimkey'];
}
} else {
header('Location:index.html');
}
mysqli_close($con);
?>
</html>
<? ob_flush(); ?>
When I try this, password not working and key.php shows every single
bizimkey strings.
Please help :(

No comments:

Post a Comment