Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. <?php
  2. /**
  3. @author : Shubham Maurya,
  4. **/
  5.  
  6. make a file in notepad and save it as class.User.php and paste the below code.
  7.  
  8. <?php
  9.  
  10. /**
  11. *
  12. */
  13. class USER
  14. {
  15. private $db;
  16.  
  17. //Constructor
  18. function __construct($DBcon)
  19. {
  20. $this->db=$DBcon;
  21. }
  22.  
  23.  
  24.  
  25. //Signup
  26. public function signup($email,$code)
  27. {
  28.  
  29. try {
  30.  
  31. $stmt=$this->db->prepare("INSERT into users(email,joindate,token_Code) VALUES(:email, CURRENT_TIMESTAMP , :code )");
  32.  
  33. if($stmt->execute(array(':email'=>$email ,':code'=>$code)))
  34. {
  35. return $stmt;
  36. }
  37.  
  38. } catch (PDOException $e)
  39. {
  40. echo $e->getMessage();
  41. }
  42.  
  43.  
  44. }
  45.  
  46.  
  47.  
  48.  
  49. //Redirect
  50. public function redirect($url)
  51. {
  52. header("Location: $url");
  53. exit();
  54. }
  55.  
  56.  
  57. //Send Mail
  58. function send_mail($email,$message,$subject)
  59. {
  60. require_once('mailer/class.phpmailer.php');
  61. $mail = new PHPMailer();
  62. $mail->IsSMTP(); //Remove if mail is not sending..
  63. $mail->SMTPDebug = 0;
  64. $mail->SMTPAuth= true;
  65. $mail->SMTPSecure="ssl";
  66. $mail->Host="smtp.gmail.com";
  67. $mail->Port=465;
  68. $mail->AddAddress($email);
  69. $mail->Username="[email protected]";
  70. $mail->Password="Submitted11@";
  71. $mail->SetFrom('[email protected]');
  72. $mail->Subject = $subject;
  73. $mail->MsgHTML($message);
  74. $mail->Send();
  75. return true;
  76. }
  77.  
  78.  
  79. //Get Last Inserted Id
  80. public function lastID()
  81. {
  82. $stmt = $this->db->lastInsertId();
  83. return $stmt;
  84. }
  85.  
  86.  
  87. }
  88. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement