mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-27 07:49:27 +00:00
Created a function to check email address
This commit is contained in:
parent
c44ee1cb1b
commit
993319057a
@ -113,6 +113,25 @@ function postInt(string $name) : int {
|
|||||||
return (int)$_POST[$name];
|
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)
|
* Securely transform user given number (mixed) to integer (int)
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user