Cant time in on database and time out newbie here


#1

public function index()
{
if($this->request->is([‘post’]))
{

		$someVariable = $this->request->getData("username"); 
		$stampsTable = TableRegistry::get('Stamps');
		$stamp = $stampsTable->newEntity();
		
		
		$dteNow = Date::now();
		$tmeNow = Time::now();
		
	
		
		$answer = $_POST['Type'];  
		
		
		if ($answer == 1) {         
		$query = $stampsTable->find()->where(['username' => $someVariable, 'outin' => 1]);	
			if ($query->isEmpty()) 
			{
			$stamp->username = $someVariable;
			$stamp->tin =$tmeNow;
			$stamp->datenow= Date::now();
			$stamp->outin=1;
				if ($stampsTable->save($stamp)) 
				{
				$this->Flash->success(__('The stamp has been saved.'));
				}
			}else{		
			$this->Flash->error(__('The stamp is already existing! Please try again!'));
			}
		}elseif($answer==2){
			$affectedRows=$stampsTable->updateAll(array("tout" => $tmeNow,"outin"=>2),array("username IN" => $someVariable , "dateNow IN"=>$dteNow,"outin"=>1));
			if($afftectedRows=1)
			{
			$this->Flash->success(__('The stamp has been saved.'));
			}
		}else{
			$this->Flash->error(__('Complete the form to proceed!'));
			}
			
		$this->Flash->error('Access Denied!');
		
	}
	{
	$users = $this->paginate($this->Users);
	$this->set(compact('users'));
}


#2

Turn on debug and you will get a more verbose error message what will help you identify the source of the error.


#3

this might creating issue as class Date and Time is not found on this scope, you shoud add " \ " or " / " before this class name