Mam obecnie formularz rejestracji i osobne stronke.php ktora wszystko przetwarza. Ponizej znajduje sie kawalek kodu. Chce zastapic obecna forme sprawdzania poprawnosci email na ta ktora znajduje sie pod skrawkiem ponizszego kodu ale nie chce dzialac, tzn uzytkownik wpisujac np. "rjfsndvnd" jako email wciaz moze wyslac formularz.
Ma ktos pomysl jak to robic by chodzilo?
Probowalem juz ten kod wstawic w obecny lub wkleic do osobnego pliku i zalaczyc jako 'include' ale nic...
<?php
if (isset($_POST['Submit']))
{
//Validate form
$errormessage = "";
$no_Win_OS = "Win OS";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if ($name == '') { $errormessage .= "<li>Please provide your User Name</li>";}
if ($Email == '') { $errormessage .= "<li>Please provide your e-mail address</li>";}
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $Email)){ $errormessage = $errormessage . "<li>Please provide a valid e-mail address</li>";}
if ($iPAD_model == '0') { $errormessage .= "<li>Please provide your iPAD capacity</li>";}
if ($Win_OS == '0') { $errormessage .= "<li>Please provide your Win OS version</li>";}
if ($iOS == '0') { $errormessage .= "<li>Please provide your iOS version</li>";}
if ($Wi_Fi == '0') { $errormessage .= "<li>Please provide your Wi-Fi connection type</li>";}
//if ($existing_user == "yes") && ($details == ''){ $errormessage .= "<li>Please provide details</li>";}
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
$errormessage .= "<li>The reCAPTCHA wasn't entered correctly. <br>
Go back and try it again.</li>";
}
echo "</ul></p>";
//If errors, return error message(s) and form
if ($errormessage != "")
{ ?>
________________________________________________________________________________
function check_email_address($mail) {
// First, we check that there's one @ symbol,
// and that the lengths are right.
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $Email)) {
// Email invalid because wrong number of characters
// in one section or wrong number of @ symbols.
return false;
}
// Split it into sections to make life easier
$email_array = explode("@", $Email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if
(!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$",
$local_array[$i])) {
return false;
}
}
// Check if domain is IP. If not,
// it should be valid domain name
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) {
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
return false; // Not enough parts to domain
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if
(!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$",
$domain_array[$i])) {
return false;
}
}
}
return true;
}