PDA

View Full Version : $pages code not redirecting properly..



sweaverit
11-18-2007, 09:20 AM
I do not know PHP... yet! But I am learning.

This should be simple for all the coders on here.. lol.

I'm using this code for redirecting to a certain page on specified days of the week, and times:


<?php
session_start();

//check to see if the date and time is Thursday between 7pm and 9pm
if (date('H') >= 4 && date('H') <= 5 && date('l') == 'Sunday') {
$_SESSION['goforit'] = 'yes';

//or you can comment the above and put the chat functions here
}

else {
$_SESSION['goforit'] = 'no';
}

if ($_SESSION['goforit'] == 'yes') {

header('Location: http://www.arpast.org/chat/cwamod.php'); //redirect to chat page
}

?>

This redirects you to an enter page for my chat room, but only on Thursdays after 7PM and before 9PM.

Thats working fine.

But, I want to specify a $page name for the page that it redirects to in an attempt to "hide" the URL of it, or at least mask it. If it isn't hidden, people can just go directly to the entrance page URL... which is not good, because then I have no control over who enters when, rendering the first code completely useless.

In my attempt, I used the following code directly below the code I posted above:

<?php $pages = Array('chat' => 'http://www.arpast.org/chat/cwamod.php');?>

This code supposedly will make the url in the address bar look like "http://www.arpast.org/chat/index.php?page=chat" instead of "http://www.arpast.org/chat/cwamod.php".

But it returned a "This page is not re-directing properly" error.

I tried it above the first piece of code, and it returned the same error.

* Do I need to put this code somewhere else?
* Does this code even work for what I am wanting it to do?!
* Is it possible to "blend" the two codes to make them work with each other?

Please help! :eek:

Thanks in advance,
Suzanne

tech_support
11-18-2007, 09:34 AM
Try this:


<?php
session_start();

//check to see if the date and time is Thursday between 7pm and 9pm
if (date('H') >= 4 && date('H') <= 5 && date('l') == 'Sunday') {
$_SESSION['goforit'] = 'yes';

//or you can comment the above and put the chat functions here
}

else {
$_SESSION['goforit'] = 'no';
}

if ($_SESSION['goforit'] == 'yes') {

include('chat/cwamod.php'); //includes the chat page.
}

?>

sweaverit
11-18-2007, 09:37 AM
Woah, haha.

Okay that put a view of the entrance page above the regular index page.

tech_support
11-18-2007, 09:43 AM
Ok... after the include('chat/.....'); put die();

Like this:


<?php
session_start();

//check to see if the date and time is Thursday between 7pm and 9pm
if (date('H') >= 4 && date('H') <= 5 && date('l') == 'Sunday') {
$_SESSION['goforit'] = 'yes';

//or you can comment the above and put the chat functions here
}

else {
$_SESSION['goforit'] = 'no';
}

if ($_SESSION['goforit'] == 'yes') {

include('chat/cwamod.php'); //includes the chat page.
die();
}

?>

sweaverit
11-18-2007, 09:45 AM
Yes!! That worked!

Thank you so much. :)