<?php
// checks if the request exists and isnt empty
if(isset($_POST['domains']) && !empty($_POST['domains'])){
// using explode you can also put how mainy domains you want, like, explode("\n",$_POST['domains'], 3), you can change 3 for other numer but
// put the number of domains is optional
$domains = explode("\n",$_POST['domains']);
$validDomains = array();
// check id there are valid domain
foreach($domains as $domain){
if(preg_match(/*some regerex expresion to check if element is a valid domain*/, $domain)){
$validDomain = strtolower($domain);
$validDomain = str_replace("www." , "" , $validDomain);
$validDomain = str_replace(" " , "" , $validDomain);
array_push($validDomains, $validDomain)
} else {
// handle error, like a error message
// or continue with the loop without put the domain in $validDomains
continue
}
}
// do something with $domains, that is a array
// redirect to other page or something
}
?>