nicx Posted June 18, 2008 Share Posted June 18, 2008 Admin n guys,plz help me.My problem: i want to make a page in my site can only visiting my users in time 6.OO AM - 5.00 PM,so user can't visit my page without/past that time. How to create the sintax?? Using if argument? Plz help me with write down the sintax here thx b4. Quote Link to comment Share on other sites More sharing options...
Stephen Posted June 18, 2008 Share Posted June 18, 2008 Try to try it yourself first and if you have problems post here. PHP.net is your friend. But heres a code: <?php $_hour=date("G"); //Returns the string value of the hour in 24 hour format //Below will check if its less than 5AM or greater than 6PM (18) if (intval($_hour)<5 && intval($_hour)>18) { ?> Your HTML code here <?php } else { echo("Please return again between 5AM and 6PM"); //Displays this message if it isn't between 5AM and 6PM } ?> I didn't test it, tell me if it works. By the way, intval converts from a string value to an integer value. Quote Link to comment Share on other sites More sharing options...
nicx Posted June 18, 2008 Author Share Posted June 18, 2008 Thankz bro,sorry b4 coz i am a newbie.Ok i will try it. Quote Link to comment Share on other sites More sharing options...
serverman Posted June 18, 2008 Share Posted June 18, 2008 well thatsa by your servers time not by the client or viewers time... is there a way to get clients time via php.... you can always use javascript to tell the server what time it is Quote Link to comment Share on other sites More sharing options...
xtopolis Posted June 18, 2008 Share Posted June 18, 2008 Clients can't be trusted! Don't tell the server what to do Quote Link to comment Share on other sites More sharing options...
grlayouts Posted June 18, 2008 Share Posted June 18, 2008 wonder if it would work with days. Quote Link to comment Share on other sites More sharing options...
nicx Posted June 19, 2008 Author Share Posted June 19, 2008 I was test now,i dont know that work or not. I was waiting for the time. Quote Link to comment Share on other sites More sharing options...
serverman Posted June 19, 2008 Share Posted June 19, 2008 just change the time on your computer(server) or are you not the host sometimes i forget that not everyone is there own host lol Quote Link to comment Share on other sites More sharing options...
nicx Posted June 19, 2008 Author Share Posted June 19, 2008 Guys,i need your help again. I have 2 page and that conected by session..Thats: page1.php: <?php session_start(); $_SESSION['string'] = 'string'; ?> page2.php: <?php session_start(); if(!isset($_SESSION['string'])) die("You must enter from page 1.php.."); //so,user can enter this page from page 1. My question: how to sett expire time from that session?? If i want sett that to 20 minutes expire? And how to protect page2.php from wrap,coz someone make wrapped of page2.php Quote Link to comment Share on other sites More sharing options...
Stephen Posted June 19, 2008 Share Posted June 19, 2008 Instead of a session you could use a cookie that expires in 20 minutes. Page1: <?php setcookie("string","allow",time()+1200); //1200 = 20 minutes (60 sec * 20) ?> Page2: <?php if (!isset($_COOKIE["string"])) { die("You must enter from page1.php."); } //so,user can enter this page from page 1. EDIT: Btw I think I messed up on that code. Try this: <?php $_hour=date("G"); //Returns the string value of the hour in 24 hour format //Below will check if its less than 5AM or greater than 6PM (18) if (intval($_hour)>5 && intval($_hour)<18) { ?> Your HTML code here <?php } else { echo("Please return again between 5AM and 6PM"); //Displays this message if it isn't between 5AM and 6PM } ?> xD I switched > and < around. Quote Link to comment Share on other sites More sharing options...
nicx Posted June 19, 2008 Author Share Posted June 19, 2008 Ok,i will try this.Coz the old tag was you give not work hihi. Quote Link to comment Share on other sites More sharing options...
nicx Posted June 19, 2008 Author Share Posted June 19, 2008 @stephen,if i use cookie..How to conect page1 and page2 with <a href=..? Coz if i use session,i usualy write <a href=\"page2.php?".sid."\>page2</a>. Like this. How with cookie? Quote Link to comment Share on other sites More sharing options...
Stephen Posted June 19, 2008 Share Posted June 19, 2008 Just go to page2.php. The cookie works throughout your site and you don't need to have it in the URL. Quote Link to comment Share on other sites More sharing options...
nicx Posted June 19, 2008 Author Share Posted June 19, 2008 Ok,thx hehe.Btw the code <?php $_hour = date ( "G" ); //Returns the string value of the hour in 24 hour format //Below will check if its less than 5 AM or greater than 6 PM (18) if ( intval ( $_hour )> 5 && intval ( $_hour )< 18 ) { ?> Your HTML code here <?php } else { echo( "Please return again between 5 AM and 6PM" ); //Displays this message if it isn't between 5 AM and 6PM } ?> was not work,i wait reach now.But my page not open.Plz change the time to GMT +7 Quote Link to comment Share on other sites More sharing options...
Stephen Posted June 19, 2008 Share Posted June 19, 2008 It works for me. It's the servers time it checks, I'm not sure how to do the clients time. Quote Link to comment Share on other sites More sharing options...
nicx Posted June 19, 2008 Author Share Posted June 19, 2008 But i was wait from yesterday until now.My page not open?!.. How to show my host server time? Use time() ? Quote Link to comment Share on other sites More sharing options...
nicx Posted June 19, 2008 Author Share Posted June 19, 2008 @stephen,plz visit my site www.coolzero.co.cc and choose bomber link. You will know that not work...Plz any mistake with your tag?? Or on time setting? Quote Link to comment Share on other sites More sharing options...
Stephen Posted June 19, 2008 Share Posted June 19, 2008 Instead of the intval($_hour)>5 && intval($_hour)<18 Did you put intval($_hour)>9 && intval($_hour)<15 Otherwise it wouldn't work between 9am and 3pm. Quote Link to comment Share on other sites More sharing options...
nicx Posted June 19, 2008 Author Share Posted June 19, 2008 I'm input (intval($_hour)>2 && intval($_hour)< n that work now..Hihi. I want it work at 9am until 3pm time server.What i must input? And i want to show server time now to client,how the sintax? Using time() ?? Quote Link to comment Share on other sites More sharing options...
nicx Posted June 19, 2008 Author Share Posted June 19, 2008 Bos,plz help me how to protect my page from wrapping? Coz my page was wrapped by someone and he use to flood my gb.Plz help..Can i protect with cookies? Quote Link to comment Share on other sites More sharing options...
Stephen Posted June 19, 2008 Share Posted June 19, 2008 What do you mean wrapping? Quote Link to comment Share on other sites More sharing options...
nicx Posted June 19, 2008 Author Share Posted June 19, 2008 Wrapping is curl post.So,user can post from other site using curl without enter my wap Quote Link to comment Share on other sites More sharing options...
nicx Posted June 20, 2008 Author Share Posted June 20, 2008 Bro,btw using cookies in my page there are any browser not support cookies. Plz explain how to set time in a session?? Quote Link to comment Share on other sites More sharing options...
nicx Posted June 20, 2008 Author Share Posted June 20, 2008 Master! Plz help me to make a session for my page,coz i was try but that not perfect. I have 2 page,they are page1.php and page2.php. I want to connect page1 and page2 with session. So,user who enter page2 he can't enter that page before,he through page1.php. And if he enter page1.php he get session to enter page2.php.And that session expire in 20minutes, How with session sintax?? And i wan't the url in page2.php become domain.com/page2.php?sid=xxxx because session i'm create can't show url like that. Plz help with the sintax.Thanks Quote Link to comment Share on other sites More sharing options...
nicx Posted June 20, 2008 Author Share Posted June 20, 2008 Master! Plz help me to make a session for my page,coz i was try but that not perfect. I have 2 page,they are page1.php and page2.php. I want to connect page1 and page2 with session. So,user who enter page2 he can't enter that page before,he through page1.php. And if he enter page1.php he get session to enter page2.php.And that session expire in 20minutes, How with session sintax?? And i wan't the url in page2.php become domain.com/page2.php?sid=xxxx because session i'm create can't show url like that. Plz help with the sintax.Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.