Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_GET['submitButton'])) {
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "php_vaje";
- // Create connection
- $conn = new mysqli($servername, $username, "", $dbname);
- // Check connection
- if ($conn->connect_error) {
- $error = "Mysql base is not running, please try again later.";
- }
- if ($error === null) {
- $name = $_GET['nameBox'];
- $password = $_GET['passwordBox'];
- $sql = "SELECT name FROM uporabnik WHERE name='$name' AND password ='$password";
- $nameFromBase = $conn->query($sql);
- $sql = "SELECT ID FROM uporabnik WHERE name = '$name' AND password = '$password";
- $IDFromBase = $conn->query($sql);
- }
- $conn->close();
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css" integrity="sha384-Smlep5jCw/wG7hdkwQ/Z5nLIefveQRIY9nfy6xoR1uRYBtpZgI6339F5dgvm/e9B" crossorigin="anonymous">
- <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/js/bootstrap.min.js" integrity="sha384-o+RDsa0aLu++PJvFqy8fFScvbHFLtbvScb8AjopnFD+iEQ7wo/CG0xlczd+2O/em" crossorigin="anonymous"></script>
- <title>User login page</title>
- <body>
- <div class="row">
- <div class="offset-lg-5 col-lg-2 offset-2 col-8">
- <div class="card mt-5">
- <div class="card-body">
- <form action="register.php" method="get">
- <div class="form-group">
- <label for="exampleInputEmail1">Username</label>
- <input name="nameBox" type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Username" required>
- </div>
- <div class="form-group">
- <label for="exampleInputPassword1">Password</label>
- <input name="passwordBox" type="password" class="form-control" id="exampleInputPassword1" placeholder="Password" required>
- </div>
- <div class="form-group">
- <label for="exampleInputPassword1">Repeat password</label>
- <input name="passwordBox2" type="password" class="form-control" id="exampleInputPassword1" placeholder="Repeat password" required>
- </div>
- <center>
- <a name="submitButton" type="submit" class="btn btn-primary">Login</a>
- </center>
- <?php
- if ($IDFromBase->num_rows > 0) {
- // output data of each row
- echo "lala!", $nameFromBase = $row['name'];
- $password = $row['password'];
- }
- else {
- echo "0 results";
- }
- $conn->close();
- ?>
- Welcome! This is your page.
- }
- </form>
- </div>
- </div>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement