"; global $wpdb; // Check if form has been submitted if (isset($_POST['submit'])) { // Get email addresses from input area $email_list = $_POST['email_list']; // Replace with the name of your input field $emails = explode("\n", $email_list); // Split input into an array of email addresses // Loop through email addresses and insert into database foreach ($emails as $email) { $email = trim($email); // Remove any leading or trailing whitespace $email = strtolower($email);//converts an email address to lowercase if (filter_var($email, FILTER_VALIDATE_EMAIL)) { // Validate email address $hash_email = substr(hash('sha256', $email), 0, 40); $wpdb->insert( 'aigc_purchaser', array( 'email' => $hash_email ), array( '%s' ) ); echo $email ."\t" .$hash_email ."
"; }else{ echo "E-mail is not valid:" .$email ."
"; } } // Display success message echo '

Email addresses have been added to the database.

'; } else { // Display form echo '

'; // Display list of email addresses $results = $wpdb->get_results("SELECT * FROM aigc_purchaser"); if ($results) { echo '

List of email addresses:

'; echo ''; } }