Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $stmt = $DB_con->prepare("SELECT user_name,user_email FROM users WHERE user_name=:uname OR user_email=:umail");
- <?php
- session_start();
- $DB_host = "localhost";
- $DB_name = "dbeva";
- $DB_user = "root";
- $DB_pass = "";
- try {
- $DB_con = new PDO("mysql:host={$DB_host};dbname={$DB_name}",$DB_user,$DB_pass);
- $DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- echo "<div class='bildirim'>- Veritabanına Bağlandı !</div>";
- }
- catch(PDOException $e) {
- echo $e->getMessage();
- echo "<div class='bildirim'>- Veritabanı Bağlantısı Başarısız !</div>";
- }
- include_once 'userclass.php';
- $user = new user($DB_con);
- ?>
- <?php
- class user {
- private $db;
- function __construct($DB_con) {
- $this->db = $DB_con;
- echo "<div class='bildirim'>- Constructor Çalıştı !</div>";
- } // Constructor Function
- public function check($cuname,$cumail,$cupass) {
- if ($cuname == "") {
- echo "<div class='bildirim'>Kullanıcı adı boş bırakılamaz.</div>";
- } // if $cuname == ""
- else if (strlen($cuname) < 6 && strlen($cuname) > 15) {
- echo "<div class='bildirim'>Kullanıcı adı 6 ile 15 karakter arasında olmalıdır.</div>";
- } // else if 6 <= $cuname <= 15
- else if ($cumail == "") {
- echo "<div class='bildirim'>Email boş bırakılamaz.</div>";
- } // else if $cumail == ""
- else if (!filter_var($cumail, FILTER_VALIDATE_EMAIL)) {
- echo "<div class='bildirim'>Lütfen geçerli bir mail adresi girin.</div>";
- } // else if validate email
- else if ($cupass == "") {
- echo "<div class='bildirim'>Şifre boş bırakılamaz.</div>";
- } //else if $cupass == ""
- else if (strlen($cupass) < 6) {
- echo "<div class='bildirim'>Şifre en az 6 karakter olmalıdır.</div>";
- } // else if $upass < 6
- else {
- try {
- $stmt = $DB_con->prepare("SELECT user_name,user_email FROM users WHERE user_name=:uname OR user_email=:umail");
- $stmt->execute(array(':uname'=>$cuname, ':umail'=>$cumail));
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
- if($row['user_name'] == $cuname) {
- echo "<div class='bildirim'>Üzgünüz, kullanıcı adı çoktan alınmış.</div>";
- } // if user_name exist
- else if($row['user_email'] == $cumail) {
- echo "<div class='bildirim'>Üzgünüz, sitemizde bu mail adresi ile kayıtlı bir üye zaten var.</div>";
- } // else if user_email exist
- else {
- try {
- $new_pass = password_hash($cupass, PASSWORD_DEFAULT);
- $stmt = $this->db->prepare("INSERT INTO users(user_name,user_email,user_pass)
- VALUES(:uname,:umail,:upass)");
- $stmt->bindparam(":uname", $cuname);
- $stmt->bindparam(":umail", $cumail);
- $stmt->bindparam(":upass", $new_pass);
- $stmt->execute();
- return $stmt;
- echo "<div class='bildirim'>- Kayıt İşlemi Başarılı !</div>";
- } // try register
- catch(PDOException $e) {
- echo $e->getMessage();
- echo "<div class='bildirim'>- Kayıt İşlemi Başarısız !</div>";
- } // catch register
- } // else
- } // try check
- catch (PDOException $e) {
- echo $e->getMessage();
- } // catch check
- } // else
- } // Function Check
- } // User Class
- ?>
- <?php
- require_once "dbconfig.php";
- if (isset($_POST['btn_signup'])) {
- $r_uname = trim($_POST['r_uname']);
- $r_uname = strip_tags($r_uname);
- $r_umail = trim($_POST['r_umail']);
- $r_umail = strip_tags($r_umail);
- $r_upass = trim($_POST['r_upass']);
- $r_upass = strip_tags($r_upass);
- $user->check($r_uname,$r_umail,$r_upass);
- } // if isset btn_signup
- if (isset($_POST['btn_login'])) {
- //$user->login();
- } // if isset btn_signup
- ?>
- <html>
- <head>
- <head>
- <title>Eva Login System</title>
- <meta charset="UTF-8">
- <link rel="stylesheet" type="text/css" href="style.css"/>
- <link href='https://fonts.googleapis.com/css?family=Open+Sans:' rel='stylesheet' type='text/css'>
- </head>
- </head>
- <body>
- <div class="formwrapper">
- <h2>Giriş Yap !</h2>
- <form method="post" action="">
- <input class="inputa" type="text" name="l_umail" placeholder="Email">
- <input class="inputa" type="password" name="l_upass" placeholder="Şifre">
- <input class="inputb" type="submit" name="btn_login" value="Giriş Yap">
- </form>
- </div>
- <div class="formwrapper">
- <h2>Bize Katıl !</h2>
- <form method="post" action="">
- <input class="inputa" type="text" name="r_uname" placeholder="Kullanıcı Adı">
- <input class="inputa" type="text" name="r_umail" placeholder="Email">
- <input class="inputa" type="text" name="r_upass" placeholder="Şifre">
- <input class="inputb" type="submit" name="btn_signup" value="Hesap Aç">
- </form>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement