Advertisement
Guest User

Untitled

a guest
Nov 8th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. <input type="text" name="aname" />
  2. <input type="email" name="aemail" />
  3. <input type="password" name="apassword" />
  4. <input type="password" name="txtcpass" />
  5. <input name="btn-signup" value="Sign Up">
  6.  
  7. require_once 'class.user1.php';
  8. $reg_user = new USER();
  9.  
  10. if ($reg_user->is_logged_in() != "") {
  11. $reg_user->redirect('profile.php');
  12. }
  13.  
  14.  
  15. if (isset($_POST['btn-signup'])) {
  16.  
  17. $aname = trim($_POST['aname']);
  18. $aemail = trim($_POST['aemail']);
  19. $apassword = password_hash($_POST['apassword'], PASSWORD_DEFAULT);
  20. $cpass = trim($_POST['txtcpass']);
  21. $code = md5(uniqid(rand()));
  22.  
  23.  
  24. $stmt = $reg_user->runQuery("SELECT * FROM admin WHERE aemail=:email_id");
  25. $stmt->execute(array(":email_id" => $aemail));
  26. $row = $stmt->fetch(PDO::FETCH_ASSOC);
  27.  
  28.  
  29. if ($aemail == "") {
  30. $error[] = "provide email id !";
  31. } else if (!filter_var($aemail, FILTER_VALIDATE_EMAIL)) {
  32. echo "<b>This is not a valid email address.</b>";
  33. } else if ($stmt->rowCount() > 0) {
  34. $msg = "
  35. <div class='alert alert-error'>
  36. <button class='close' data-dismiss='alert'>&times;</button>
  37. <strong>Sorry !</strong> email allready exists , Please Try another one
  38. </div>
  39. ";
  40. } else {
  41. if ($reg_user->register($aname, $aemail, $apassword, $code)) {
  42. $id = $reg_user->lasdID();
  43. $key = base64_encode($id);
  44. $id = $key;
  45.  
  46. $message = "msg1";
  47.  
  48.  
  49. $subject = "Confirm Registration";
  50.  
  51. $reg_user->send_mail($aemail, $message, $subject);
  52. $msg = " msg2";
  53.  
  54. } else {
  55. echo "sorry , Query could no execute...";
  56. }
  57. }
  58. }
  59.  
  60. require_once 'dbconfig.php';
  61. const PATH_PHOTOS = '/var/www/html/sbdev2/php/site6/upload/';
  62. global $_FILES;
  63.  
  64. class USER
  65. {
  66.  
  67. private $conn;
  68.  
  69. public function __construct()
  70. {
  71. $database = new Database();
  72. $db = $database->dbConnection();
  73. $this->conn = $db;
  74. }
  75.  
  76. public function runQuery($sql)
  77. {
  78. $stmt = $this->conn->prepare($sql);
  79. return $stmt;
  80. }
  81.  
  82. public function lasdID()
  83. {
  84. $stmt = $this->conn->lastInsertId();
  85. return $stmt;
  86. }
  87.  
  88. public function register($aname, $aemail, $apassword, $code)
  89. {
  90. try {
  91.  
  92.  
  93. $stmt = $this->conn->prepare("INSERT INTO admin(aname, aemail, apassword, tokenCode) ;");
  94. $stmt->execute(array(
  95. ":aname" => $aname,
  96. ":aemail" => $aemail,
  97. ":apassword" => $apassword,
  98. ":active_code" => $code
  99. ));
  100. return $stmt;
  101. } catch (PDOException $ex) {
  102. echo $ex->getMessage();
  103. }
  104. }
  105.  
  106.  
  107. public function update($aname, $aemail)
  108. {
  109. try {
  110. $stmt = $this->conn->prepare('UPDATE admin SET aname = ?, aemail = ? WHERE adminID = ? ');
  111. return $stmt->execute(array($aname, $aemail, $_SESSION['userSession']));
  112. } catch (PDOException $e) {
  113. echo '<p class="bg-danger">' . $e->getMessage() . '</p>';
  114. }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement