Slater8242 0 Posted Sunday at 07:41 PM Report Share Posted Sunday at 07:41 PM 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 Quote Link to post Share on other sites
niche 133 Posted Tuesday at 12:47 AM Report Share Posted Tuesday at 12:47 AM What's your question? Quote Link to post Share on other sites
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.