Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <body>
- <?php
- // connect to the mysql database
- $con = new mysqli("127.0.0.1","root","seedubuntu","test_cms");
- // get the user data
- $username = $_POST['user'];
- $password = $_POST['password'];
- // query the database
- $sql = "SELECT username FROM users WHERE username = ? AND password = ?";
- $stmt = $con->prepare($sql);
- $stmt->bind_param("ss",$username,$password);
- $stmt->execute();
- $stmt->store_result();
- $number_of_results = $stmt->num_rows;
- if ($number_of_results == 0)
- {
- print "Wrong username/password <br>";
- }
- else
- {
- $stmt->bind_result($name);
- $stmt->fetch();
- print "Welcome ".$name."! You are logged in.<br>";
- }
- // close the connection to the database
- $stmt->close();
- mysqli_close($con);
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment