Jump to content

Nothing happens :O


Beppis

Recommended Posts

Nothing happens :o I want it to redirect you to another page

 

<?php

if(!isset($_COOKIE['language']))
{
    if(!isset($_POST['submit']))
    {
    ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><? include("title.php"); ?></title>
<style type="text/css">
<!--
body {
background-image: url(images/background.jpg);
}
-->
</style></head>

<body>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p><br>
    <br>
  <br />
  <br />
</p>
<div align="center">
  <table width="200" border="0">
    <tr>
    <form action="language.php" method="post">
    <td width="114"><div align="left"><input type="image" src="images/swe.jpg" border="0" name="swedish" alt="swedish"></div></td>
         <td width="1"> </td>
      <td><div align="left"></div></td>
    <td><input type="image" src="images/usa.jpg" border="0" name="usa" alt="ssa"></td>
</form>
    </tr>
    <tr>
      <td><div align="center"><strong>SWE</strong></div></td>
      <td> </td>
      <td width="0"><div align="center"></div></td>
      <td width="110"><div align="center"><strong>USA</strong></div></td>
    </tr>
  </table>
  
</div>
<p align="center"> </p>
</body>
</html>
<?php

if (isset($_GET['language']))
{
    // return lang (convert it to entities
    // to prevent any XSS attacks)
    $lang = htmlspecialchars($_GET['language']);

    // store for next time
    setcookie('language', htmlspecialchars($_GET['language']));
}
elseif (isset($_COOKIE['language']))
{
    // set lang var
    $lang = $_COOKIE['language'];
}

if (!isset($lang))
{
    // if no $lang var set, use default
    $lang = 'en';
}

if(!isset($_COOKIE['language']))
{
    if(!isset($_POST['submit']))
    {
    ?>
        <?php
    }
    else
    {
        $language = $_POST['language'];
        setcookie("language", $language, time()+3600);;//set to expire in 1 hour, 3600=seconds
        
        switch($language)
        {
            case usa:
                $redirect = "http://www.clickbuxer.com";
                break;
            case swedish:
                $redirect = "http://www.clickbuxer.com/sv/index.php";
                break;
            default:
                $redirect = "http://www.clickbuxer.com";
        }
        
        header("Location: $redirect");
    }
}
else
{
    $language = $_COOKIE['language'];
    
    switch($language)
    {
        case usa:
            $redirect = "http://www.clickbuxer.com";
            break;
        case swedish:
            $redirect = "http://www.clickbuxer.com/sv/index.php";
            break;
        default:
            $redirect = "http://www.clickbuxer.com";
        }
        
    header("Location: $redirect");
}
}
}


?>

Link to comment
https://forums.phpfreaks.com/topic/210490-nothing-happens-o/
Share on other sites

Did you really just bump this thread after 10 minutes? Impatient much?

 

To answer your question, the script doesn't hit the header() redirect unless $_COOKIE['language'] and $_POST['submit'] are set. However, if those are both set, there is HTML output to the browser before the header(), so it won't redirect anyhow, it will just trigger an error.

Link to comment
https://forums.phpfreaks.com/topic/210490-nothing-happens-o/#findComment-1098290
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.