jduke6 Posted September 17, 2011 Share Posted September 17, 2011 function isValidEmail($email){ return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email); } How do I incorporate the code above into my code?? <?php error_reporting(E_ALL ^ E_NOTICE); ?> <?php // make sure the form has actually been submitted . . . if( strtolower($_SERVER['REQUEST_METHOD']) === 'post' ) { // 1. Create a database connection $connection = mysql_connect("localhost", "root", "maven777"); if(!$connection){ die("Database connection failed: " .mysql_error()); } // 2. Select a database to use $db_select = mysql_select_db("homesloans", $connection); if(!$db_select){ die("Database selection failed: " .mysql_error()); } $radius = ($_POST['radius']); $type = ($_POST['type']); $price = ($_POST['price']); $bedrooms = ($_POST['bedrooms']); $bathrooms = ($_POST['bathrooms']); $parking = ($_POST['parking']); $city = ($_POST['city']); $details = ($_POST['details']); $firstname = ($_POST['firstname']); $lastname = ($_POST['lastname']); $email = ($_POST['email']); $phone = ($_POST['phone']); $query="INSERT INTO leads (leadid, city, radius, type, price, bedrooms, bathrooms, parking, details, firstname, lastname, email, phone) VALUES('NULL', '[$city]', '[$radius]', '[$type]', '[$price]', '[$bedrooms]', '[$bathrooms]', '[$parking]', '[$details]', '[$firstname]', '[$lastname]', '[$email]', '[$phone]')"; mysql_query($query) or die ('Error updating database'); echo "Database Successfully Updated."; // not necessarily. The only way to know for sure is to check that mysql_affected_rows() > 0 } ?> Quote Link to comment https://forums.phpfreaks.com/topic/247320-email-verification-at-least-verify-its-in-e-mail-form/ Share on other sites More sharing options...
jdock1 Posted September 17, 2011 Share Posted September 17, 2011 The absolute best email validation solution atleast in my opinion is is_email http://code.google.com/p/isemail/ I incorporate it into all of my sites. It verifys addresses against all RFC codes Quote Link to comment https://forums.phpfreaks.com/topic/247320-email-verification-at-least-verify-its-in-e-mail-form/#findComment-1270185 Share on other sites More sharing options...
joel24 Posted September 17, 2011 Share Posted September 17, 2011 what about PHP's filter_var function? I'm sure there are issues, feel free to inform me. function checkEmail($email) { return filter_var($email, FILTER_VALIDATE_EMAIL); } Quote Link to comment https://forums.phpfreaks.com/topic/247320-email-verification-at-least-verify-its-in-e-mail-form/#findComment-1270188 Share on other sites More sharing options...
cssfreakie Posted September 17, 2011 Share Posted September 17, 2011 if you just want to verify it's an emailaddress i would go for the native filter_var function. saves 52kb. Quote Link to comment https://forums.phpfreaks.com/topic/247320-email-verification-at-least-verify-its-in-e-mail-form/#findComment-1270199 Share on other sites More sharing options...
voip03 Posted September 17, 2011 Share Posted September 17, 2011 jduke6, I am not hijacking your post. cssfreakie, joel24 Can you give your comments about this article? http://www.eddieoneverything.com/articles/validating-an-email-address-with-phps-filter_var-isnt-perfect.php Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/247320-email-verification-at-least-verify-its-in-e-mail-form/#findComment-1270215 Share on other sites More sharing options...
cssfreakie Posted September 17, 2011 Share Posted September 17, 2011 jduke6, I am not hijacking your post. cssfreakie, joel24 Can you give your comments about this article? http://www.eddieoneverything.com/articles/validating-an-email-address-with-phps-filter_var-isnt-perfect.php Thank you. https://bugs.php.net/bug.php?id=49576 see comments... Quote Link to comment https://forums.phpfreaks.com/topic/247320-email-verification-at-least-verify-its-in-e-mail-form/#findComment-1270219 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.