我一直试图纠正这个问题8个小时。 不能从HTML输入变量为什么?我不明白一切看起来都很正常吗?
---------以下是真实且相同的代码,但使用我的母语--------------------
--- 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代码部分
<?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 ----这是数据库连接部分。
更新:删除评论
-------------- var_dump post ---
array(3) { ["kuladi"]=> string(6) "asdasd" ["sifre"]=> string(6) "asdasd" ["submit"]=> string(8) " Giriş " }
[07-May-2014 23:49:59] PHP警告:session_start():无法发送会话cookie - 已经发送的标头(输出始于C:\ apache2triad \ htdocs \ proje anket \ giris_yap_php.php:5 )在第15行的C:\ apache2triad \ htdocs \ proje anket \ giris_yap_php.php
更新:我删除了seesion_start()并且你们所有人都说它现在有效了谢谢:=)happyy
答案 0 :(得分:1)
我认为这可能是编码问题,因为我在HTML中看到了一些utf-8字符
将<meta http-equiv="content-type" content="text/html;charset=utf-8" />
添加到您的html标题
修改表单<form action="login.php" method="POST" accept-charset="UTF-8">
答案 1 :(得分:1)
<?php
$kadi = $_POST['kulladi'];
应该是
$kadi = $_POST['kuladi'];
因为您使用name="kuladi"
作为表单元素。