Jump to content

(ask)Wapsite with time limit!


nicx

Recommended Posts

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.

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

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.

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.