Last active
December 13, 2016 19:52
-
-
Save toddnestor/8605330 to your computer and use it in GitHub Desktop.
What PHP OOP can do...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//require prepend file | |
require('minicore/_conf/conf.php'); | |
//Call for necessary class families from herccore | |
using ('System.Data'); | |
using ('System.Validation'); | |
//make class definitions | |
$insertData = new insertData(); | |
$validation = new isDataType(); | |
//first check to see if the email is already in the table, if it not and it actually is an email address add it | |
if($insertData->check_if_unique('email',$_POST['email'],'newsletter') && $validation->isEmail($_POST['email'])) $insertData->insertSQL(array('email'),'newsletter'); | |
//no matter what happens send them right back to the returnpage that is held in the hidden input named 'returnPage' | |
header('Location: '.$_POST['returnPage']); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This little program only works with my particular framework but wanted to demonstrate what using OOP in php can do. It takes the post data (an email field and a hidden returnpage field) and first checks to see if the email is already in the newsletter table, and then verifies it is an email address. If it is then it adds it to the table and then sends them on back to the return page.
This took less than a minute to make, though it isn't exactly an amazing feature it does demonstrate how making good classes in php can help speed up programming.