Kod dodający (do niego trzeba połączyć w jeden skrypt drugą część):
<?php $mail = escape_data($_POST['mail']); $ip=$REMOTE_ADDR; $host=gethostbyaddr($ip); $query2 = "INSERT INTO newsttler ( mail, data, ip, host) VALUES ( '$mail', NOW(), '$ip', '$host' )"; }else{ echo '<div align="center"><font color="red" align=center>Twój adres nie został dodany</font></div>'; }} echo' <form name="wpisz" action="index.php" method="post"> <tr><td align="center"> <input type="text" name="mail" value="Twój adres e-mail"/></td></tr> <tr><td align="center"> <input type="hidden" name="ip" value="'.$ip.'" /> <input type="hidden" name="host" value="'.$host.'" /> <input type="submit" name="wpisz" value="Dopisz się" /></form>'; ?>
I Skrypt sprawdzajacy:
<?php function verifyEmail($mail) { $wholeexp = '/^(.+?)@(([a-z0-9.-]+?).[a-z]{2,5})$/i'; $userexp = "/^[a-z0-9~!#$%&()-_+=[];:'",./]+$/i"; if (preg_match($wholeexp, $mail, $regs)) { $nick = $regs[1]; $host = $regs[2]; if (checkdnsrr($host, MX)) { if (preg_match($userexp, $nick)) { return true; } else { return false; } } else { return false; } } else { return false; } } ?>