COOKIEを使ってログイン情報を記録しようとしたのですが、
if($_COOKIE['email'] !=''){
$_POST['email']=$_COOKIE['email'];
$_POST['password']=$_COOKIE['password'];
$_POST['save']='on';
}
の箇所で
Notice: Undefined index: email in /home/ubuntu/public_html/login.php on line 6
というエラーが出ました。
ググってもイマイチ分からなかったのでご回答よろしくお願い致します。
<?php require('dbconnect.php'); session_start(); if($_COOKIE['email'] !=''){ $_POST['email']=$_COOKIE['email']; $_POST['password']=$_COOKIE['password']; $_POST['save']='on'; } if(!empty($_POST)){ //ログインの処理 if($_POST['email'] !='' && $_POST['password'] !='' ){ $login=$db->prepare('SELECT * FROM members WHERE email=? AND password=?'); $login->execute(array($_POST['email'],shal($_POST['password']))); $member=$login->fetch(); if($member){ //ログイン成功 $_SESSION['id']=$member['id']; $_SESSION['time']=time(); //ログイン情報を記録する if($_POST['save']=='on'){ setcookie('email', $_POST['email'], time()+60*60*24*14); setcookie('password', $_POST['password'], time()+60*60*24*14); } header('Location: index.php'); exit(); }else{ $error['login']='failed'; } }else{ $error['login']='blank'; } } $name = ""; if (isset($_POST['name'])) { $name = $_POST['name']; } $email = ""; if (isset($_POST['email'])) { $email = $_POST['email']; }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。