Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <input type="text" name="aname" />
- <input type="email" name="aemail" />
- <input type="password" name="apassword" />
- <input type="password" name="txtcpass" />
- <input name="btn-signup" value="Sign Up">
- require_once 'class.user1.php';
- $reg_user = new USER();
- if ($reg_user->is_logged_in() != "") {
- $reg_user->redirect('profile.php');
- }
- if (isset($_POST['btn-signup'])) {
- $aname = trim($_POST['aname']);
- $aemail = trim($_POST['aemail']);
- $apassword = password_hash($_POST['apassword'], PASSWORD_DEFAULT);
- $cpass = trim($_POST['txtcpass']);
- $code = md5(uniqid(rand()));
- $stmt = $reg_user->runQuery("SELECT * FROM admin WHERE aemail=:email_id");
- $stmt->execute(array(":email_id" => $aemail));
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
- if ($aemail == "") {
- $error[] = "provide email id !";
- } else if (!filter_var($aemail, FILTER_VALIDATE_EMAIL)) {
- echo "<b>This is not a valid email address.</b>";
- } else if ($stmt->rowCount() > 0) {
- $msg = "
- <div class='alert alert-error'>
- <button class='close' data-dismiss='alert'>×</button>
- <strong>Sorry !</strong> email allready exists , Please Try another one
- </div>
- ";
- } else {
- if ($reg_user->register($aname, $aemail, $apassword, $code)) {
- $id = $reg_user->lasdID();
- $key = base64_encode($id);
- $id = $key;
- $message = "msg1";
- $subject = "Confirm Registration";
- $reg_user->send_mail($aemail, $message, $subject);
- $msg = " msg2";
- } else {
- echo "sorry , Query could no execute...";
- }
- }
- }
- require_once 'dbconfig.php';
- const PATH_PHOTOS = '/var/www/html/sbdev2/php/site6/upload/';
- global $_FILES;
- class USER
- {
- private $conn;
- public function __construct()
- {
- $database = new Database();
- $db = $database->dbConnection();
- $this->conn = $db;
- }
- public function runQuery($sql)
- {
- $stmt = $this->conn->prepare($sql);
- return $stmt;
- }
- public function lasdID()
- {
- $stmt = $this->conn->lastInsertId();
- return $stmt;
- }
- public function register($aname, $aemail, $apassword, $code)
- {
- try {
- $stmt = $this->conn->prepare("INSERT INTO admin(aname, aemail, apassword, tokenCode) ;");
- $stmt->execute(array(
- ":aname" => $aname,
- ":aemail" => $aemail,
- ":apassword" => $apassword,
- ":active_code" => $code
- ));
- return $stmt;
- } catch (PDOException $ex) {
- echo $ex->getMessage();
- }
- }
- public function update($aname, $aemail)
- {
- try {
- $stmt = $this->conn->prepare('UPDATE admin SET aname = ?, aemail = ? WHERE adminID = ? ');
- return $stmt->execute(array($aname, $aemail, $_SESSION['userSession']));
- } catch (PDOException $e) {
- echo '<p class="bg-danger">' . $e->getMessage() . '</p>';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement