Advertisement
Larry_Poistone

Untitled

Dec 23rd, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.79 KB | None | 0 0
  1. <?php
  2. /*
  3.    require 'database.php' ;
  4.    $message = '' ;
  5.    $server = 'localhost' ;
  6.    $username = 'root';
  7.    $password = 'root';
  8.    $database = 'auth';
  9.  
  10.    try { $conn = new PDO("mysql:host=$server; dbname=$database;", $username,$password);
  11.    } catch(PDOException $e){
  12.      die("Connection failed:". $e->getMessage());
  13.    } */
  14. if (!empty($_POST['email']) && !empty($_POST['password'])) {
  15.   //if ($_POST['confirm_password']=== $_POST['password']
  16.    $sql = "INSERT INTO users (email,password) VALUES(:email,:password) "
  17.     $stmt = $conn->prepare($sql) ;
  18.     $stml ->blindParam(':email',$_POST['email']);
  19.     $stml ->blindParam(':password', password_hash($_POST['password'], PASSWORD_BCRYPT ));
  20.     if( $stmt->execute() ):
  21.        $message = "Successfully created new account";
  22.     else:
  23.       $message = "Fail" ;
  24.  
  25. }
  26. ?>
  27. <! выше идут комментарии из-за того что я на могу присоединится к базе данных >
  28. <!DOCTYPE html>
  29. <html>
  30.   <head>
  31.     <link href='http//fonts.googleapis.com/css?family=Comfortaa'>
  32.     <link rel="stylesheet" type="text/css" href="Assets\Style.css">
  33.     <meta charset="utf-8">
  34.     <title>Register</title>
  35.   </head>
  36.   <body>
  37.     <div class="header">
  38.       <a href="Site.php">Your app name</a>
  39.  
  40.     </div>
  41.      <?php if(!empty($message)):
  42.        echo "$message";
  43.        ?>
  44.     <h2>Register</h2>
  45.     <span> or <a href="Login.php">Login</a></span>
  46.     <form class="" action="Register.php" method="post">
  47.       <input type="text" name="email" placeholder="Enter Your email">
  48.       <input type="password" name="password" placeholder="Enter Your Password">
  49.       <input type="password" name="confirm_password" placeholder="Confirm Your Password">
  50.       <input type="submit">
  51.  
  52.  
  53.     </form>
  54.   </body>
  55. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement