connection=new DataBase(); $this->send_to = $this->strip_code($_POST['username']); $this->come_from = $_SESSION['username']; $this->time_sent = ""; $this->subject = $this->strip_code($_POST['subject']); $this->message = $this->strip_code($_POST['message']); $this->privatem = $this->strip_code($_POST['private']); $this->time_sent = date('Y-m-d H:i:s'); if($this->message && strlen($this->message)>6) { if($this->subject) { if($this->come_from) { if($this->send_to) { if($this->privatem) { $this->send(); } else { $this->privatem = "n"; $this->send(); } } else { echo("I don't know who to send this message to!"); } } else { echo("Please Login"); } } else { echo("Please enter a subject"); } } else { echo("Message too short."); } } function send() { if($this->send_to!=$this->come_from) { $this->connection->Query("SELECT username FROM users WHERE username='$this->send_to'"); if($this->connection->TotalRows()>0) { $this->connection->Query("INSERT INTO user_pm (to_id, from_id, time_sent, subject, message, opened, private) VALUES ('$this->send_to', '$this->come_from', '$this->time_sent', '$this->subject', '$this->message', 'n', '$this->privatem')"); echo("Message has been sent to send_to ."\">". $this->send_to . ""); $this->connection->Close(); } else { echo("The username does not exist"); } } else { echo("You can not send a message to yourself"); } } function strip_code($value){ if (get_magic_quotes_gpc()) { $value = stripslashes($value); $value = htmlspecialchars($value); $value = mysql_real_escape_string($value); } return $value; } } ?>