Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.76 KB | None | 0 0
  1. <?php  
  2.   require 'dbconnect.php';
  3. ?>
  4. <html>
  5. <head>
  6.   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
  7.   <link rel="stylesheet" href="style.css">
  8. </head>
  9. <body>
  10.   <h3>Admin Page  <a href="./">Back to Homepage</a></h3>
  11.   <a href="dbreset.php">Reset Database</a>
  12.   <hr>
  13.  
  14.   <h3>Add User</h3>
  15.   <p>Firstname:</p>
  16.   <input type="text" id="fname">
  17.   <p>Lastname:</p>
  18.   <input type="text" id="lname">
  19.   <p>Username:</p>
  20.   <input type="text" id="uname">
  21.   <p>Password:</p>
  22.   <input type="password" id="pass">
  23.   <p>Password2:</p>
  24.   <input type="password" id="pass2">
  25.   <br>
  26.   <br>
  27.   <button onclick="adduser()">Add User</button>
  28.  
  29.   <hr>
  30.   <br><br>
  31.   <div id="result"></div>
  32.  
  33.   <hr>
  34.   <br>
  35.   <h3>Data Dump of Database Below</h3>
  36.   <?php include 'db2array.php'; include 'printall.php'; ?>
  37.  
  38.   <script>
  39.    
  40.     function adduser(){
  41.       console.info('Adding User...');
  42.      
  43.       //var regex = /^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{8,}$/;
  44.       var regex = /^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)[A-Za-z\d$@$!%*#?&]{8,}$/;
  45.       if($('#pass').val() != $('#pass2').val()){
  46.         alert('Passwords do not match!');
  47.         return false;
  48.       }
  49.       if(!regex.test($('#pass').val())){
  50.         alert('Password must have at least one number and one letter, and one capital letter and be at least 8 characters long');
  51.         return false;
  52.       }
  53.      
  54.      
  55.       $.post( "adduser.php", { firstname: $('#fname').val(), lastname: $('#lname').val(), username: $('#uname').val(), password: $('#pass').val()})
  56.         .done(function( data ) {
  57.           console.log( "User Added: " + data );
  58.           $('#result').html(data);
  59.         });
  60.      
  61.     }
  62.  
  63.   </script>
  64. </body>
  65. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement