<?php
$mysql_user = "root";
$mysql_pwd 	= "";
$mysql_db 	= "buttonoil_football_fakers";
$connection = mysqli_connect("localhost", "root", "", "buttonoil_football_fakers");

if ($connection -> connect_errno) {
    die();
}

require_once 'vendor/autoload.php';
$faker = Faker\Factory::create();
//print_r($faker);
for ($i = 1; $i <=43; $i++) {
    $email = preg_replace('/@example\..*/', '@gmail.com', $faker->unique()->safeEmail);
    $password_hash = password_hash($faker->password,PASSWORD_BCRYPT);
    $token = md5(rand().time());
    $randow_points = rand(30, 80);
    //$sql = "INSERT INTO users (username, email, password, token, is_active,ip, date_time) VALUES ('{$faker->name}','{$email}','{$password_hash}','{$token}','1','{$faker->ipv4}', now())";
    $sql = "INSERT INTO 
        users (username, email, password, token, is_active, points_earned, ip, date_time) 
        VALUES ('{$faker->name}','{$email}', '{$password_hash}', '{$token}', '1', '{$randow_points}', '{$faker->ipv4}', now())";

    $sqlQuery = mysqli_query($connection, $sql);
    if(!$sqlQuery){
        print_r($sql);
        die("MySQL query failed!" . mysqli_error($connection));
    }
}
echo 'Success';


