General

Validating emails with php

Sanitizing and validating email syntax $email = $_POST[’email’]; //getting the posted email //sanitizing the email using FILTER_SANITIZE_EMAIL //removes all illegal e-mail characters from a string $email=filter_var($email, FILTER_SANITIZE_EMAIL); //validating the email using FILTER_VALIDATE_EMAIL //validates e-mail returning true if valid and false if invalid (filter_var($field, FILTER_VALIDATE_EMAIL)) ? TRUE : FALSE; Creating a function to validate and sanitize

Validating emails with php Read More »

Sending emails with php

Set up the variables: $to = “email@address.com”; //where the email will go $subject = “Our Subject”; //the subject $message = “The message to send”; //the message $from = “you@email.com”; //from email $header = “From: $from”; //header including the from email Sending the email: mail($to, $subject, $message, $header); //send the email Sending the email and returning

Sending emails with php Read More »

Scroll to Top