Jump to content

Page loads only after refresh


Apyvala

Recommended Posts

Hi,

i have a website on three speeches - Lithuania ( lt ), English ( en ) and Russian ( ru ). Website on one server works perfect, but on another server not.

In index file i have such code:

if (!session_is_registered("speech")) {
if ($_SESSION['speech'] == "") {
session_register("speech");
$_SESSION['speech'] = "lt";
}

that is, default speech is lt. Moreower i have three links:

<a href="change_speech.php?speech=lt" class="speech">LT</a> <a href="change_speech.php?speech=en" class="speech">EN</a> <a href="change_speech.php?speech=ru" class="speech">RU</a>

My change_speech.php file looks:

<?php
session_start();

$_SESSION['speech'] = $_GET['speech'];

header ("Location: index.php");
?>


The problem: when i push on links "LT", "EN" or "RU" i see white page, i need to push F5 ( to refresh page ) than i could see the page.
This problem occurs only on one server, on another server i haven't such problem.

Any ideas?
Link to comment
Share on other sites

[!--quoteo(post=367461:date=Apr 22 2006, 10:13 AM:name=Apyvala)--][div class=\'quotetop\']QUOTE(Apyvala @ Apr 22 2006, 10:13 AM) [snapback]367461[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Hi,

i have a website on three speeches - Lithuania ( lt ), English ( en ) and Russian ( ru ). Website on one server works perfect, but on another server not.

In index file i have such code:

if (!session_is_registered("speech")) {
if ($_SESSION['speech'] == "") {
session_register("speech");
$_SESSION['speech'] = "lt";
}

that is, default speech is lt. Moreower i have three links:

<a href="change_speech.php?speech=lt" class="speech">LT</a> <a href="change_speech.php?speech=en" class="speech">EN</a> <a href="change_speech.php?speech=ru" class="speech">RU</a>

My change_speech.php file looks:

<?php
session_start();

$_SESSION['speech'] = $_GET['speech'];

header ("Location: index.php");
?>
The problem: when i push on links "LT", "EN" or "RU" i see white page, i need to push F5 ( to refresh page ) than i could see the page.
This problem occurs only on one server, on another server i haven't such problem.

Any ideas?
[/quote]


try exit(); after the header call in change_speech.php. I have found that you have to force some browsers to do that header function.
Link to comment
Share on other sites

Thank you for suggestions. But my website doesn't work well after the you suggested changes.

I has perceived an interesting thing. I am using:

HTML code:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


then i change it to:

<meta http-equiv="Content-Type" content="text/html; charset=win-1257" />


Than the website works well. Hmmm... it is very interesting for me.

win-1257 - Lithuanian encoding
Link to comment
Share on other sites

When using sessions, make sure you have [code]<?php session_start(); ?>[/code] at the start of each script where sessions are being used. Do not use the functions session_is_registered() and session_register(). Instead use [code]<?php if (!isset($_SESSION['var])) ?>[/code] for [code]<?php if (!session_is_registered('var') ?>[/code]

So your index.php code should look something like:
[code]<?php
session_start();
if (!isset($_SESSION['speech']) || (isset($_SESSION['speech']) && $_SESSION['speech'] == '')))
     $_SESSION['speech'] = 'lt';
?>[/code]

In your change_speech.php code, you should do something like:
[code]<?php
session_start();
$_SESSION['speech'] = (isset($_GET['speech']))?$_GET['speech']:'lt';
?>[/code]

Ken
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.