Location: PHPKode > projects > Thought Push PHP Framework > instance/controllers/contact.php
<?

if($_POST && $_SESSION['contact']){
	$message = trim($_POST['message']);
	if(!$message){
		Page::setError('Message not entered');
	}
	$email = trim($_POST['email']);
	if(!preg_match('@^[a-z\.0-9_\-]+\@[a-z\.0-9\-]+$@i',$email)){
		Page::setError('Email is malformed');
	}
	$name = trim($_POST['name']);
	if(!$name){
		Page::setError('Name not entered');
	}
	if(!Page::$errors){
		if(!$_SESSION['contacted'] || $_SESSION['contacted'] < strtotime('-1 day')){
			$contacted = Db::row('select 1 from contact where ip = '.Db::quote($_SERVER['REMOTE_ADDR']).' and time > '.strtotime('-1 day'));
			if(!$contacted){
				Db::insert('contact',array('name'=>$name,'message'=>$message,'email'=>$email,'ip'=>$_SERVER['REMOTE_ADDR'],'time'=>time()));
				$_SESSION['contacted'] = time();
				Page::setMessage('You\'re message has been sent.');
			}else{
				Page::setError('Wait one day before submitting another contact form.');
			}
		}else{
			Page::setError('Wait one day before submitting another contact form.');
		}
	}
}


$_SESSION['contact'] = true;


Display::show(array(
			array(
				'standardPage','',array(
					array('standardFullPage',null,'contact')
				)
			)
		)
	);
Return current item: Thought Push PHP Framework