사용자가 등록하고 로그인 할 수있는 index.php 페이지가 있습니다. 사용자가 로그인하면 Welcome Admin을 표시하고 싶습니다. 세션이 null이라는 것을 알고 $_SESSION
이 null이 될 수 있습니까? 세션은 항상 null을 반환합니다.
<?php
session_start();
try {
$db = new PDO("mysql:host=127.0.0.1; dbname=blog", "root", "");
} catch (PDOException $ex) {
echo $ex->getMessage();
}
$v = $db->prepare("select * from uyeler where uye_sifre=? and uye_ad=?");
var_dump($v);
if ($_POST) {
$isim = $_POST["isim"];
$sifre = $_POST["sifre"];
$v->execute(array($sifre, $isim));
$x = $v->fetchAll(PDO::FETCH_ASSOC);
$d = $v->rowCount();
if ($d) {
$_SESSION["ad"] = $x["uye_ad"];
$_SESSION["sife"] = $x["uye_sifre"];
$_SESSION["durum"] = $x["uye_durum"];
echo "Giriş başarılı";
} else {
echo "Geçersiz Kullanıcı";
}
} else {
if ($_SESSION) {
var_dump($_SESSION);
echo "adam üye";
} else {
echo '<form action="" method="post">
<table cellpadding="5" cellspacing="5">
<tr>
<td>Uye Ad</td>
<td><input type="text" name="isim" id=""></td>
</tr>
<tr>
<td>Uye Şifre</td>
<td><input type="password" name="sifre" id=""></td>
</tr>
<tr>
<td><input type="submit" id=""></td>
</tr>
</table>
</form>';
}
}
?>
이
는 위해서 var_dump 출력wamp64\www\indeks.php:12:
object(PDOStatement)[2]
public 'queryString' => string 'select * from uyeler where uye_sifre=? and uye_ad=?' (length=51)
C:\wamp64\www\indeks.php:34:
array (size=3)
'ad' => null
'sife' => null
'durum' => null
어떤 오류가 당신이 얻을 않았다 그래서이 라인이에
해결 ? '$ _SESSION' 배열은'session_start()'가 사용되기 전에 호출되지 않았거나 헤더가 설정되기 전에 출력이 시작된 결과로서 실패한 경우에만 null입니다. 두 경우 모두 PHP는 확실히 당신에게 문제를 디버깅하기 위해 알아야 할 모든 것을 알려주는 상세한 오류를 줄 것입니다. 오류 정보를 공유하면 정보를 좁힐 수 있습니다. – Sherif
주제를 업데이트했습니다. –
오류가 세션이 아니므로 귀하의 질문이 반환됩니다! – Provie9