<?php
require_once "../system/constant.php";
$mysqli =mysqli_connect(hostname,dbuser,dbpass,dbname);
 
if(isset($_POST["cat"]) && !empty($_POST["cat"])){
    //Get all state data
	$cat = $_POST["cat"];
	$query = $mysqli->query("SELECT * FROM sub_categories where cat_id = '$cat'");
    
    //Count total number of rows
    $rowCount = $query->num_rows;
    
    //Display states list
    if($rowCount > 0){
        echo '<option value="">Select Subcategory</option>';
        while($row = $query->fetch_assoc()){ 
            echo '<option value="'.$row['id'].'">'.$row['subcategory_name'].'</option>';
        }
    }else{
        echo '<option value="">Sub category not available</option>';
    }	
	
    
}
/*************forget pass change members***********/
if(isset($_POST['usub']) && isset($_POST['upass']) && $_POST['uidu']) :
if($_POST['upass'] == $_POST['ucpass']) :
    $password = $_POST['upass'];
    $options = ['cost' => 10];			
    $pass = password_hash($password, PASSWORD_BCRYPT, $options);
    $idu = $_POST['uidu'];
    $query = $mysqli->query("update users set password = '$pass'  where id = '$idu'");
    if($query) :
        $update = $mysqli->query("update resetpwd_token set status = '1' where uid = '$idu'");
        if($update){
            $mysqli->query("delete from resetpwd_token where status = 1");
        }
        echo 'Successfully reset';
    else :
        echo '<div class="alert alert-danger" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><strong>Failed!</strong> Request Failed!</div>';
        endif;
    else :
    echo '<div class="alert alert-danger" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><strong>Failed!</strong> Confirm Password Not Match!</div>';

endif;
endif;
?>