[ create a new paste ] login | about

Link: http://codepad.org/7PsanZIO    [ raw code | output | fork ]

PHP, pasted on Aug 8:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php 
$postEmail = 'user@university.ac.uk'; // as $_POST["uni_email"]
if (empty ($postEmail)) {
    $emailErr2 = "University email is required";
} else {
    $uemail = $postEmail;
    if ( !filter_var($uemail, FILTER_VALIDATE_EMAIL)) {
    $emailErr3 = "Invalid email format";
     echo $emailErr3;
    }
}

if (substr(trim($postEmail), -6) === '.ac.uk') {
  echo 'email is correct';
} else {
  $emailErr3 = "Invalid university email format";
  echo $emailErr3;
}
?>


Output:
1
email is correct


Create a new paste based on this one


Comments: