Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <link href="test.css" type = "text/CSS" rel = "stylesheet" >
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
- <script type="text/javascript" src="scrpt.js"></script>
- </head>
- <body>
- <form>
- <label> First Name: </label>
- <br>
- <input class = "inp" type = "text" name = "fname" id = "fname"> </input>
- <br>
- <label> Last Name: </label>
- <br>
- <input class = "inp" type = "text" name = "lname" id = "lname"> </input>
- <br>
- <label> Email: </label>
- <br>
- <input class = "inp" type = "text" name = "email" id = "email"> </input>
- <br>
- <label> Username: </label>
- <br>
- <input class = "inp" type = "text" name = "usrname" id = "usr"> </input>
- <br>
- <label> Password: </label>
- <br>
- <input class = "inp" type = "password" name = "psw" id = "psw"> </input>
- <br>
- <input type = "submit" id = "submit" > </input>
- <br>
- <label> Login: </label>
- <br>
- <input class = "inp" type = "text" name = "login" id = "log"> </input>
- <br>
- <label> Password: </label>
- <br>
- <input class = "inp" type = "password" name = "logPsw" id = "logPsw"> </input>
- <br>
- <input type = "submit" id = "logSub" > </input>
- </form>
- </body>
- </html>
- $(document).ready(function(){
- $("#submit").click(function(){
- var fn = $("#fname").val();
- var ln = $("#lname").val();
- var email = $("#email").val();
- var usr = $("#usr").val();
- var psw = $("#psw").val();
- $.ajax(
- {
- type: "POST",
- url: "register.php",
- data: {
- fname: fn,
- lname: ln,
- email: email,
- usr: usr,
- psw: psw
- },
- success: function(result){
- }
- }
- );
- });
- $('#logSub').click(function(){
- var login = $("#log").val();
- var psw = $("#logPsw").val();
- $.ajax(
- {
- type: "POST",
- url: "login.php",
- data: {
- login: login,
- password: psw
- },
- success: function(result){
- alert(""+result);
- }
- }
- );
- });
- });
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "admin_db";
- $conn = new mysqli($servername, $username, $password, $dbname);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $login = $_POST['login'];
- $psw = $_POST['password'];
- $sql = "select * from user where userName = "$login" and password = "$psw"";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- echo "Yes";
- }
- else{
- echo "No Such Account";
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement