-1

is it possible to check the Url with regex to validate?

URL looks: https://www.example.com/secure/index.phpID=name@specialDomain.com

in the domain our marketing division can input an mail address only with -> @domain.com or domain-marketing.com .

(marketing division input the email address in the Url, send the link to User, they input her data and send the form to the *@domain.com or *@domain-marketing.com)

thanks

  • It might be my understanding, but I really can't work out what the question is here. Are you able to edit your question to make it a little clearer? – DaveyDaveDave Apr 10 '17 at 12:40
  • for example: URL -> https://www.domian.com/secure/index.php?ID=john.doe@domain.com OR ......doe.john@domain-test.com i will only @domian.com and domain-test-com Domain works after enter . If it is an other domain (...@gmail.com) i will get an Forbidden. – j_spaceman Apr 19 '17 at 12:46

1 Answers1

0

Solve this issue:

$email = $_GET['ID']; // remember to filter this!
$regex = '#\w+@(?<domain>\w+\-?\w+\.\w+)#';

preg_match($regex, $email, $matches);
$domain = $matches['domain'];

if ($domain !== 'example-test.com') {
    // Unauthorised
}