Hello, what im trying to do with this php code is first check if $string1 is equal to $string2, that part works great, when the strings are equal it echos some javascript code. The problem is the cookie check php, If the strings are equal i want it to check if cookie exist, If i does then redirect, if it dont exist then move on to the javascript code, Now when i run the check cookie by itself it works great, but when added to this code it is ignored and dont work, What am i doing wrong here?
<?php
$string1 = $row['title'];
$string2 = ["Game One", "Game Two", "Game Three"];
// Check if any of the titles in $string2 are equal to $string1
foreach ($string2 as $title) {
if ($title == $string1) {
// Check if the cookie 'myCookie' exists
if (isset($_COOKIE['myCookie'])) {
// Send the redirect header
header('Location: https://www.mywebsite.com');
echo <<<EOF
<script type="text/javascript">
//Run some javascript code
</script>
EOF;
}
}
?>
[MOD: added "code" tags]