How would i create a script that would take a user to a page at a certain time and wouldn't take them there again until the next day at the same time?
Thanks
How would i create a script that would take a user to a page at a certain time and wouldn't take them there again until the next day at the same time?
Thanks
May need some modification, and it is not tested.
Hope this helps.Code:<?php $redirect_Start = "1400"; //don't redirect before 2pm $redirect_End = "1500"; //don't redirect after 3pm $redirect_To = "redirect.php"; //where to redirect to if (date('Gi') >= $redirect_Start && date('Gi') <= $redirect_End) { header('Location: '.$redirect_To); } else { //whatever you want } ?>
//EDIT: new addition to code is not tested Modifications are in red. Let me know if it doesn't and I will work on fixing it.
Last edited by thetestingsite; 04-13-2007 at 11:40 PM.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design
That would work, I think, but why would you redirect at only exactly 2pm?
That would only do it for that specific time. I guess it might do the whole hour, but I'm not sure.
I'd think a range would be better, or just "after 2pm", etc.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
Yea, that script will only redirect a user at 2pm (not 2:01 or 1:59, but 2pm on the dot). I was working on adding to it, but went to lunch and this slipped my mind. Thanks for bringing this back up, djr33.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design
This should work... change as needed--
PHP Code:<?php
$redirect_Time = "1400"; //redirect at 2pm
$redirect_Flex = "30"; //.5hr flexiblity (1:30-2:30)
$redirect_To = "redirect.php"; //where to redirect to
if (date('Gi') >= $redirect_Time-$redirect_Flex && date('Gi') <= $redirect_Time+$redirect_Flex) {
header('Location: '.$redirect_To);
}
else {
//whatever you want
}
?>
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
i have a problem with "tts" code:
it says there is a problem with the:Code:<?php $redirect_Start = "1300"; //don't redirect before 8pm $redirect_End = "1400"; don't redirect after 9pm $redirect_To = "javascript:buildtimeP()"; //where to redirect to if (date('Gi') >= $redirect_Start && date('Gi') <= $redirect_End) { header('Location: '.$redirect_To); } else { //whatever you want } ?>
part.Code:if (date('Gi') >= $redirect_Start && date('Gi') <= $redirect_End) {
The only thing I can see with the code you posted is an uncommented line:
The part in red is what needs to be added, other than that the code should work fine.Code:<?php $redirect_Start = "1300"; //don't redirect before 8pm $redirect_End = "1400"; //don't redirect after 9pm $redirect_To = "javascript:buildtimeP()"; //where to redirect to if (date('Gi') >= $redirect_Start && date('Gi') <= $redirect_End) { header('Location: '.$redirect_To); } else { //whatever you want } ?>
Hope this helps.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design
I don't believe you can redirect to a javascript: pseudo-URL in a Location header.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Yes, I think that's only an anchor property... I'll test it though.
- Mike
Hmm. Type this into your url:
Seems to work.Code:javascript:alert(typeof window);
- Mike
Bookmarks