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();



}

}

}

?>

Link to comment
Share on other sites

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. 

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.