host = $host; $this->username = $username; $this->password = $password; $this->table = $db; $this->connect(); } /** Generates and sends a email to notify users of their email */ function sendEmail($userEmail, $title, $body){ mail( $userEmail , $title , $body); } public function email_guests($title, $body){ $r = mysql_query("SELECT * FROM guests"); if ( $r !== false && mysql_num_rows($r) > 0 ) while ( $a = mysql_fetch_assoc($r) ) $this->sendEmail($a['email'], $title, $body); } /** Display all users as links that remove them */ public function display_guest_list() { $entry_display .= '
No entries have been made on this page.
'; return $entry_display; } public function get_guest_count(){ $sql="select * from guests"; $result=mysql_query($sql); return mysql_num_rows($result); } /** inserts a new user into the database @author ricky barrette */ public function new_guest($f_name, $l_name, $address, $email, $plus_one_f_name, $plus_one_l_name) { $sql="select * from guests where email='$email'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1) // If there is a match. die("User/Email already exists"); $email = mysql_real_escape_string(strip_tags($email)); $f_name = mysql_real_escape_string(strip_tags($f_name)); $l_name = mysql_real_escape_string(strip_tags($l_name)); $address = mysql_real_escape_string(strip_tags($address)); $hash=md5($email); $sql = "INSERT INTO guests (f_name, l_name, address, email, hash, plus_one_f_name, plus_one_l_name) VALUES('$f_name','$l_name','$address','$email','$hash','$plus_one_f_name','$plus_one_l_name')"; return mysql_query($sql) or die("Could not insert. " . mysql_error()); } /** Connects to the database @author ricky barrette */ public function connect() { $connection = mysql_connect($this->host,$this->username,$this->password) or die("Could not connect. " . mysql_error()); mysql_select_db($this->table) or die("Could not select database. " . mysql_error()); return $this->buildDB(); } /** Builds the users table @author ricky barrette */ private function buildDB() { $sql = <<