쿠키에서 사용자가 입력 한 정보로 이루어진 배열에서 항목을 반환하려고하는데, 이전 페이지의 페이지를 처음 방문했을 때 아무것도 나타나지 않고 새로 고쳐야 만 괜찮습니다. 실제로 배열을 볼 수 있습니다. 나는 처음으로 왜 나타나지 않을지 전혀 모르겠다. (. 거기에 약간의 자바 스크립트 경고는 잘 작동 내가에 문제가 배열 만입니다 수 있습니다.) 여기 내 코드는 조언이 좋을 것입니다, 감사 : 당신은 읽을 수 없습니다쿠키 정보의 PHP 배열 : 페이지를 새로 고친 후에 만 표시됩니까?
$usergatsby = $_COOKIE['gatq'];
$usercatcher = $_COOKIE['catcherq'];
$userwaves = $_COOKIE['wavesq'];
$userstranger = $_COOKIE['strangerq'];
$userulysses = $_COOKIE['ulyssesq'];
$userpride = $_COOKIE['prideq'];
$usermockingbird = $_COOKIE['mockingbirdq'];
$userroad = $_COOKIE['roadq'];
if ($_COOKIE['fname'] == NULL or $_COOKIE['lname'] == NULL or $_COOKIE['address'] == NULL or $_COOKIE['city'] == NULL or $_COOKIE['state'] == NULL or $_COOKIE['zip'] == NULL or $_COOKIE['email'] == NULL)
{echo "<script language='javascript'>
window.alert('You left some information on the personal info page! You will be redirected.');
window.location.href='personal.php';</script>";
}
else
{
if ($_COOKIE['gatq'] == NULL &&
$_COOKIE['catcherq'] == NULL &&
$_COOKIE['wavesq'] == NULL &&
$_COOKIE['strangerq'] == NULL &&
$_COOKIE['ulyssesq'] == NULL &&
$_COOKIE['prideq'] == NULL &&
$_COOKIE['mockingbirdq'] == NULL &&
$_COOKIE['roadq'] == NULL)
{echo "<script language='javascript'>
window.alert('You don't have anything in your shopping cart! You will be redirected.');
window.location.href='inventory.php';</script>";
}
else
{$productarray = array($usergatsby=>'The Great Gatsby <img src="gatsby.jpg">',
$usercatcher=>'Catcher in the Rye <img src="catcher.jpg">',
$userwaves=>'The Waves <img src="waves.jpg">',
$userstranger=>'The Stranger <img src="stranger.jpg">',
$userulysses=>'Ulysses <img src="ulysses.jpg">',
$userpride=>'Pride and Prejudice <img src="pride.jpg">',
$usermockingbird=>'To Kill a Mockingbird <img src="mockingbird.jpg">',
$userroad=>'On the Road <img src="ontheroad.jpg">'
);
asort($productarray);
foreach ($productarray as $book=>$info)
{if ($book > 0)
{echo "Quantity: " . $book . " " . $info . "<br>";}
}
}
}
?>
오, 알겠습니다. 나는 그 사실을 몰랐다. 고맙습니다! – hayleyelisa