Slater8242 Posted January 10, 2021 Share Posted January 10, 2021 This is my validation function class emailValidation { public $emailMessage=""; function checkemail($emailText) { return (!preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $emailText) ) ? FALSE : TRUE; } function columbia($emailText){ return (!preg_match("/@([\w-])+\.co$/mi", $emailText)) ? FALSE : TRUE; } function validation(){ if(isset($_POST['emailSubmit'])){ if (empty($_POST["emailText"])) { $this->emailMessage = "Email is required"; } else { $emailText = $_POST["emailText"]; if (!$this->checkEmail($emailText)) { $this->emailMessage = "Invalid email format"; } if ($this->columbia($emailText)) { $this->emailMessage = "We do not accept emails from Columbia"; } } } } and this is data insert function require('dbConnection.php'); class subscribers extends dbConnection{ public function insertSubscribers(){ if (isset($_POST["emailSubmit"])) { $email=$_POST["emailText"]; $sql = "INSERT INTO subscribers (email) VALUES ('$email');"; $result = $this->connect()->query($sql); header("Location: /success.html"); } } } I am thinking to put insertSubscribers() into the validation() function Link to comment Share on other sites More sharing options...
niche Posted January 12, 2021 Share Posted January 12, 2021 What's your question? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now