Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $con = NULL;
- function connect($host, $user, $password, $db) {
- global $con;
- $con = mysqli_connect($host, $user, $password, $db);
- }
- function user_exists($username) {
- global $con;
- $query = mysqli_query($con, "SELECT * FROM users WHERE username='".$username."'");
- $userCount = mysqli_num_rows($query);
- if($userCount!=0) {
- return true;
- } else {
- return false;
- }
- }
- connect("localhost", "root", "", "vaflichka2");
- $check = user_exists("tata");
- if($check==true) {
- echo "User found!";
- } else {
- echo "User not found!";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement