Hi,
I'm transferring data from one table to another and one of the fields is an email field. I would like to check if the emailfield is empty or otherwise faulty and skip that record if it is.
This is how it looks at the moment but it's problamatic since some emails are not filled out or not correct format (spaces etc):
try {
// Define and perform the SQL SELECT query
$sqlish = "SELECT * FROM account WHERE application_type = 'NEW' and DATE(date) > DATE_SUB(CURDATE(), INTERVAL 13 DAY)";
$resultish = $DBH->prepare($sqlish);
$resultish->execute();
$number_of_rows = $result->fetchColumn();
// If the SQL query is succesfully performed ($result not false)
if($resultish !== false) {
// Parse the result set
foreach($resultish as $rowish) {
$dbfirstname = $rowish['first_name'];
$dblastname = $rowish['last_name'];
$dbemail = $rowish['email_main'];
$dbunikid = $rowish['unikid'];
$resultsbla = $DBH->prepare("insert INTO lime_tokens_262697 (firstname, lastname, email, attribute_1, emailstatus) VALUES ('$dbemail', '$dbemail', '$dbemail', '$dbunikid', 'OK')");
$resultsbla->execute();
}
}
}
catch(PDOException $e) {
echo $e->getMessage();
}
How would I change this query to also "validate" that the email looks correct and if so inserts it into specified table?
Cheers!
/Adam