Jump to content

user access 9.00 am to 6.00 pm monday to friday


mariocesar

Recommended Posts

Im using the script to let users login in to our site from 9.00 am to 6.00 pm from Monday To friday, timing is working fine but the day part don't, any ideas why, here is the top of the script is on the login.php page

 

<? 

$hour = date('H');//hour 1-24

$dayofweek = date('N');//numeric day of week 1=mon, 7=sun

if($hour < 6 || $hour > 15 || $dayofweek > 5) {

    header( "Location:Messages.php?msg=12" );

}else {

    //login code



session_start();



if(isset($_GET['reg'])){



$reg=$_GET['reg'];



}else{



$reg="";



}



if($reg==1){



$msg1="<font color=\"#FF6600\">Your details have been added, please login</font>";



}elseif($reg==2){



$msg1="<font color=\"#FF6600\">You have been successfully logged out.</font>";



}



if(isset($_POST['submit'])){



if( empty($_POST['uname']) && (empty($_POST['upass']))){



header( "Location:Messages.php?msg=1" ); 



exit();



}



//transfer to shorter var



$n=$_POST['uname'];



$p=$_POST['upass'];



//connect to db



include('config.php');



$query="SELECT * FROM user WHERE uname = '".$_POST['uname']."'



					AND pw = PASSWORD('".$_POST[upass]."')";



$result=mysql_query($query);



$num=mysql_num_rows($result);



if($num>0 ){



//put in session vars



$mytime=time();



$mytime=date("H:i:s A",$mytime);



$_SESSION['time'] = $mytime;



$_SESSION['status'] = 'logged';



$_SESSION['username'] = $n;



//goto next page



header("location:Welcome.php");



exit;



}else{



$_SESSION['status'] = 'not logged';



header( "Location:Messages.php?msg=2" ); 



exit();



}

}

}

?>

Seriously, this has broken many scripts in the past: <? Not good <?php Thats better, the parser can recognise it's own data now - time's that this has cause scripts to malfunction is amazing, reason being is because not all servers support short form tags. 

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.