سؤال

i ve been trying trying to correct this for 8 hours . cant get variable from html inputs why? i dont understand. Everything looks normal to me?

---------below is real and same code but in my native language--------------------

---giris_yap.php--- // login.php

<body>

 <form action="giris_yap_php.php"  method="POST">
   <b>Kullanıcı Adı: </b> <input type="text" name="kuladi"> <br>   
    <b>Sifre:   </b> <input type="text" name="sifre" > <br>
    <input type="submit" name="submit" value=" Giriş ">           </form>

</body>

---giris_yap_php.php--- // php code part

<?php

$kadi = $_POST['kulladi'];  //silent error's been found by SOF fellowship; happy+1
$sifre = $_POST['sifre'];
var_dump($_POST);
echo 'kull_adi : ' . $kadi .' ';   // no value comes to my screen**   

include("baglannn.php");

ob_start();
session_start();

$sql_check = mysql_query("select * from uye where kullaniciadi='".$kadi."' and kullanicisifre='".$sifre."' ") or die(mysql_error(""));

 $numrow  = mysql_num_rows($sql_check);
 echo "$numrow ";
  **if($numrow  > 0 )      // so never logins because of emtp variable comes from post**
{
     echo "num row";
    $_SESSION["login"] = "true";
    $_SESSION["user"] = $kadi;     
    $_SESSION["pass"] = $sifre;
   header("Location:index.php");
    }
else 
{   
 echo " Kullanici Adi veya Sifre Yanlis.";   // username or pass is wrong

}

---baglannn.php---- this is db connection part .

update: deleted on comment

-------------- var_dump post ---

array(3) { ["kuladi"]=> string(6) "asdasd" ["sifre"]=> string(6) "asdasd" ["submit"]=> string(8) " Giriş " }

[07-May-2014 23:49:59] PHP Warning: session_start(): Cannot send session cookie - headers already sent by (output started at C:\apache2triad\htdocs\proje anket\giris_yap_php.php:5) in C:\apache2triad\htdocs\proje anket\giris_yap_php.php on line 15

update: i deleted seesion_start() and did all of you said somehow it works now thanks :=) happyy

هل كانت مفيدة؟

المحلول

<?php

$kadi = $_POST['kulladi'];

should be

$kadi = $_POST['kuladi'];

because you are using name="kuladi" as your form element.

نصائح أخرى

I think it could be an encoding problem, since I see some utf-8 characters in your HTML

Add <meta http-equiv="content-type" content="text/html;charset=utf-8" /> to your html header

Edit your form <form action="login.php" method="POST" accept-charset="UTF-8">

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top