Jump to content

(ask)Wapsite with time limit!


nicx

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

I'm input

(intval($_hour)>2 && intval($_hour)<8)
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() ??
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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.