Forum Moderators: open

Message Too Old, No Replies

Code needed

redirect

         

craigy010

8:56 am on Oct 19, 2014 (gmt 0)

10+ Year Member



Hi all I am new to this so need help.
I am building my takeaway website and need to know hot to add a open and closed on my shop page..

I deliver from 5pm till 11:30 pm 7 days a week

I want the shop page to show, closed from 11:30 till 5 pm and then show the shop online page from 5 pm till 11:30..

I have tried this code to no avail

if now() > 17 or now() < 23.30 then
response.redirect http://example.com/Hot_Starters.html
else
response.redirect http://example.com/closed.html

[edited by: Ocean10000 at 10:26 pm (utc) on Oct 19, 2014]
[edit reason] Examplified [/edit]

mw11

1:28 am on Oct 20, 2014 (gmt 0)



Not to mention simplicity,
you would be FAR better off,
if you stated simply and elegantly
that "I deliver from 5 pm to 11:30 pm, 7 days a week".

Why? Because YOUR time is NOT necessarily their time. Because there are tremendous time zone differences as to the HOUR that is displayed on other people's computers.

And, regardless how good a script you create,
your visitors will react erratically and seemingly foolishly, depending on the HOUR that is displayed on THEIR computers.

However, if you still insist on using a code, similar to the one above, then, FYI, and for starters, let me tell you why it's not working. One reason is because the numbers '17' and '23.30' appear to be meaningless to your computer. In other words, how is your computer supposed to know that these numbers represent the hour on a(n ordinary) clock?

craigy010

8:03 am on Oct 20, 2014 (gmt 0)

10+ Year Member



In answer to your unique and quite disturbing answer. I have asked for help as to y "MY" computer doesn't know that these numbers represent the hour on a("n" ordinary) clock? "Otherwise" The clock would be working on the website and I would not be WASTING MY TIME logging in to read you wasting YOUR TIME not actually answering the QUESTION , "I ASKED" in the first place...... But thank you for your quick and not so helpful {stating the facts} answer... Is there anybody who can answer this question without sarcasm and just help me to write the code instead of telling me its wrong " I KNOW ITS WRONG ....AS IT DOES NOT WORK" Thanks for reading

tangor

9:00 am on Oct 20, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Have you looked at setting up a cron job for this purpose?

See [en.wikipedia.org...] for explanation, then search the web for "set cron job" for examples. While this is not html per se, it can be used to make a page available, or not, depending on your schedule.

Has the benefit of knowing your computer time. :)

craigy010

10:23 am on Oct 20, 2014 (gmt 0)

10+ Year Member



Thank you tangor, I will look into it :}

lucy24

3:33 pm on Oct 20, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is there anybody who can answer this question without sarcasm

I didn't see sarcasm. I saw "Have you really considered the ramifications of doing what you say you want to do?" There comes a time when answers have to fall into "Just show him how to aim the ### gun" territory ... but in the meantime it sounds appallingly as if you want a page only to be accessible at certain hours. Even if it's 8AM, human users might like to get some notion of what steps they'd have to go through if they did, some evening, want to order online. (And besides, what if they want to order now for delivery the moment the kitchen opens?)

In any case, it can't be done in HTML alone. It will be either server-side-- meaning the php or apache subforums, or equivalent for other platforms-- or javascript-- different subforum again.

craigy010

5:17 pm on Oct 20, 2014 (gmt 0)

10+ Year Member



Have you really considered the ramifications of doing what you say you want to do..? Of course I have, I have been brought up never to answer a question with a question... If when at school a teacher asks " what is 10 + 10..the answer was not "I know what the answer is, but why the question in the first place sir, figure it out yourself sir and then if you cannot , please feel free to ask me again so as I can come up with another way of expressing my inner most child by asking you another question until you demand an answer" So I guess there is no-one on this forum that can help in my quest for knowledge unless I am prepaired to read all about Java and Pearl, PHP and HTML, so as I can answer anyone questioning my knowledge with { you've guessed it} Have you really considered the ramifications of doing what you say you want to do..?... I guess another wasted five minutes of BULL is really the answer I have been looking for....OR WAS IT... Thank you LUCY 24 for reminding me that there is more to life than snotty nose college grads... I will google it...
ANOTHER WASTED RESPONSE TO A TOTALLY ACCEPTABLE PROBLEM.. And I thought this was a forum to help out others in need..

craigy010

5:19 pm on Oct 20, 2014 (gmt 0)

10+ Year Member



Is there anybody who can answer the original question or can tell me what I am doing wrong with this code from yesterday...

<?php
$time = date('Hi'); // 0000 through 2359

if($time >= '1700' && $time <= '2230') ( $loc = 'COLD_STARTERS.php'; }
else {$loc = 'closed.php'; } // if not open, it MUST be closed!
header("Location: http://example.com/{$loc}");
exit;
?>

this is a test site for the shop

[edited by: Ocean10000 at 6:04 pm (utc) on Oct 20, 2014]
[edit reason] Examplified [/edit]

jalarie

6:16 pm on Oct 20, 2014 (gmt 0)

10+ Year Member




Now=new Date();
Now_H=Now.getHours(); // 0-23
Now_N=Now.getMinutes(); // 0-59
Time=Now_H+Now_N/100;
if ((Time > 17) || (Time < 23.30)) {
response.redirect http://example.com/Hot_Starters.html
} else {
response.redirect http://example.com/closed.html
}

craigy010

7:50 pm on Oct 20, 2014 (gmt 0)

10+ Year Member



Thank you Jalarie :]