hello I am making a login/register system for my website
so far for the register php code i have:
<?php
include ("config.php");
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
$username = $_POST[username];
$password = $_POST[password];
$email = $_POST[email];
$conf_email = $_POST[confirm_email];
$query = "INSERT INTO site_users_info (username, password, email, confirm_email) VALUES('$username', '$password', '$email', '$conf_email')";
$stmt = $mysqli->prepare($query);
if(!$stmt){
echo "Problem Preparing Query!";
}
$stmt->execute();
$validatequery = "SELECT * FROM site_users_info ";
$result = mysql_query($validatequery) or die(mysql_error());;
$num_rows = mysql_num_rows($result);
?>
and here is the config file:
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
$mysqli = new mysqli("localhost", "root", "", "site_users");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
?>
the problem is I want to create an error for someone who is registering with the same username, however i have tried using the mysql_num_rows() function and i used a mysql_error to see if there was an error with the sql, it said that no database had been selected, what is causing this problem and how can i fix it?