1

Firstly my english is very bad, sorry. I'm trying to write blog in PHP. I am writing login.php. But POST method is not connected.

I write kullanici adi and sifre says:

Kullanıcı adı ve Sifre bos birakilamaz.

It's not syntax problem. I am using datagrip for database. PROBLEM if($_POST) --> Can not read it from here

<?php
if($_SESSION["login"]) // üye giris yaptımı yapmadımı session login kullanıcı girisi yapılmıssa gösterilir
{
require_once "inc/default.php";

}else {

    if($_POST)
    {

        $kadi = p("kadi"); // wherein p function
        $sifre = p("sifre");

        if(!$kadi || !$sifre){
            echo "Kullanıcı adı ve Sifre bos birakilamaz.";
        }
        else{
            $query = query("SELECT * FROM uyeler WHERE uye_kadi = '$kadi' &&  uye_sifre='$sifre' && uye_rutbe = 1");
            if(mysql_affected_rows()) // etkilenen satır varmı
            {
                $row = row($query); // row fonksiyonu çağrılır
                $session = array( // sessionlar oluşturulur.
                    "uye_id" => $row["uye_id"],
                    "uye_rutbe" => $row["uye_rutbe"],
                    "uye_kadi" => $row["uye_kadi"]
                );
                session_olustur($session);

                go(URL."/admin");
            }
            else
            {
                echo "<font color='red> Böyle bir Teknovol yöneticisi bulunmamaktadır.</font>";
            }
        }



    }

HTML :

<div id="giris_yap">
        <form action="" method="POST">
        <table cellpadding="0" cellspacing="0">
            <tr>
                <td>Kullanıcı Adı : </td>
                <td><input type="text" name="kadi"/></td>

            </tr>
            <tr>
                <td>Şifre : </td>
                <td><input type="password" name="sifre"></td>
            </tr>
            <tr>
                <td></td>
                <td><button type="submit"> Giriş yap</button> </td>
            </tr>


        </table>
        </form>
    </div>


    <?php

}

?>

p function :

function p($par,$st = false)
{
if($st)
{


    return htmlspeacialchars(addslashes(trim($_POST[$par])));

}
else
{
    return addslashes(trim($_POST[$par]));
}
}
samlev
  • 5,852
  • 1
  • 26
  • 38
Hakan san
  • 191
  • 1
  • 1
  • 9

1 Answers1

1

You have a syntax error here:

$query = query("SELECT * FROM ... 

It should be:

$query = mysql_query("SELECT * FROM ...

Add error reporting to the top of your file(s) right after your opening <?php tag error_reporting(E_ALL); ini_set('display_errors', 1); Add error checking, such as or die(mysql_error()) to your queries. Or you can find the issues in your current error logs.


Important Notes

Please stop using mysql_* functions. These extensions have been removed in PHP 7. Learn about prepared statements for PDO and MySQLi and consider using PDO, it's really pretty easy.

Your script might be at risk for SQL Injection Attacks.

Community
  • 1
  • 1
Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119