mirror of
				https://github.com/pierre42100/ComunicAPI
				synced 2025-11-04 04:04:20 +00:00 
			
		
		
		
	Created a function to check email address
This commit is contained in:
		@@ -113,6 +113,25 @@ function postInt(string $name) : int {
 | 
			
		||||
	return (int)$_POST[$name];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Get an email address specified in a $_POST request
 | 
			
		||||
 * 
 | 
			
		||||
 * @param string $name The name of the post field containing the
 | 
			
		||||
 * email address
 | 
			
		||||
 * @return string The email address
 | 
			
		||||
 */
 | 
			
		||||
function postEmail(string $name) : string {
 | 
			
		||||
 | 
			
		||||
	//Get the email as a string
 | 
			
		||||
	$email = postString($name, 5);
 | 
			
		||||
	
 | 
			
		||||
	//Check the email
 | 
			
		||||
	if(!filter_var($email, FILTER_VALIDATE_EMAIL))
 | 
			
		||||
		Rest_fatal_error(400, "Specified email address is invalid !");
 | 
			
		||||
 | 
			
		||||
	return $email;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Securely transform user given number (mixed) to integer (int)
 | 
			
		||||
 *
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user