I am facing path issue
Warning: require_once(../DB/DBConnect.php): Failed to open stream: No such file or directory in C:\xampp\htdocs\ShivLMSNew\API\insertUser.php on line 3
Fatal error: Uncaught Error: Failed opening required '../DB/DBConnect.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\ShivLMSNew\API\insertUser.php:3 Stack trace: #0 C:\xampp\htdocs\ShivLMSNew\signup.php(5): include_once() #1 {main} thrown in C:\xampp\htdocs\ShivLMSNew\API\insertUser.php on line 3
Screenshot of project directory
Screenshot of directory - Album on Imgur[
^]
What I have tried:
<?php
require_once '../DB/DBConnect.php';
$db=new DBConnect();
$pdoObj=$db->connectToDB();
$response=array();
if($_POST['radioUserType'] AND $_POST['txtUserName'] AND $_POST['txtEmail'] AND $_POST['txtMobile'] AND $_POST['txtPassword1'] AND $_POST['txtPassword2'])
{
include_once ('../Classes/SanitizerClass.php');
$userType = $_POST['radioUserType'];
$userName =SanitizerClass::sanitizeUsername($_POST['txtUserName']);
$email = SanitizerClass::sanitizeEmail($_POST['txtEmail']);
$mobile=trim($_POST['txtMobile']);
$plain_password=$_POST['txtPassword1'];
$encrypted_password = password_hash($plain_password,PASSWORD_BCRYPT);
$pwd2=$_POST['txtPassword2'];
$isEmailVerified="NotVerified";
$generated_activationCode = md5(uniqid(rand()).time());
$dateRegistered=date('d-m-Y');
$ip=crud::getVisitorIP();
include_once '../inc/crud.php';
list($CountryName,$CityName,$ContinentName,$CurrencySymbol,$CurrencyCode,$TimeZone)=CRUD::getVisitorsDetails($ip);
include_once '../Classes/User.php';
$user=new User();
$isEmailAlreadyTakenBySomeone= $user->isEmailAlreadyTakenBySomeone($email);
if($isEmailAlreadyTakenBySomeone==true)
{
$response['error'] = true;
$response['message'] = "Registration failed. Someone has already registered with the same email.";
}
else
{
$isEmailHasValidFormat = $user->isEmailHasValidFormat($email);
if($isEmailHasValidFormat==true)
{
$stmt = $conn->prepare("INSERT INTO tbl_users(userType,userName,email,mobile,password,isEmailVerified,activationCode,dateRegistered,ipAddress,countryName,cityName,continent,currencySymbol,currencyCode,timeZone)
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
$stmt->bind_param("sssssssssssssss",$userType,$userName,$email,$mobile,$encrypted_password,$isEmailVerified,$generated_activationCode,$dateRegistered,$ip,$CountryName,$CityName,$ContinentName,$CurrencySymbol,$CurrencyCode,$TimeZone);
if($stmt->execute() == TRUE)
{
$response['error'] = false;
$response['message'] = "User registered successfully!";
}
else
{
$response['error'] = true;
$response['message'] = "failed\n ".$conn->error;
}
}
else
{
$response['error'] = true;
$response['message'] = "Error in registering. Invalid Email Format.";
}
}
}
else
{
$response['error'] = true;
$response['message'] = "All fields are not filled";
}
echo json_encode($response);