Route index.php not found

I am trying to redirect based on userlevel. It was working on phpMaker2020 but after updating to to 2021 I am getting this error “Route index.php not found”. I saw that I needed to remove .php and the ID but I am still getting the error. Any advice?

function Page_Redirecting(&$url) {

	if (IsLoggedIn()) {
		if (CurrentUserlevel() == -1) {
			$url= "personal_informationlist";
		}
		elseif (CurrentUserlevel() == 1) {
			$url= "personal_informationlist";
			}
		elseif (CurrentUserlevel() == 2) {
			$url= "personal_informationlist";
		}
		elseif (CurrentUserlevel() == 10) {
			$url= "personal_informationadd";
		}
		else {
			$url = "Error404.html";
		} // <--- end of else
	} // <--- end of IsLoggedIn
}

Visit the List page of the “personal_information” table and check the URL. Normally the route should contain no underscores. Note that v2021 uses routing, your “Error404.html” will not work unless the physical file “Error404.html” actually exists.

Wow, I did not realize that the url had changed after converting to 2021. Also, yes I have the Error404.html file. The following now works. (After 3 days, can’t believe it was so simple)

// Page Redirecting event
function Page_Redirecting(&$url) {

	if (IsLoggedIn()) {
		if (CurrentUserlevel() == -1) {
			$url= "PersonalinformationList";
		}
		elseif (CurrentUserlevel() == 1) {
			$url= "PersonalinformationAdd";
			}
		elseif (CurrentUserlevel() == 2) {
			$url= "PersonalinformationAdd";
		}
		elseif (CurrentUserlevel() == 10) {
			$url= "PersonalinformationAdd";
		}
		else {
			$url = "Error404.html";
		} // <--- end of else
	} // <--- end of IsLoggedIn
}

I’m seeing something weird. I have a file being uploaded to dynamic folders. The code seems to work when I add an entry to the table but I see this notice:Notice: Trying to get property ‘CurrentValue’ of non-object in C:\xampp\htdocs\base\models\PersonalinformationAdd.php on line 1579"This is the dynamic folder code that is in the “Upload Folder” field in the File Upload selection:

Applicants/".$this->Last_Name->CurrentValue.$this->First_Name->CurrentValue.$this->ID_Number->CurrentValue."/CV/"

And this is the code listed from line 1576-1590 in C:\xampp\htdocs\base\models\PersonalinformationAdd.php

// CV
            $this->CV->EditAttrs["class"] = "form-control";
            $this->CV->EditCustomAttributes = "";
            $this->CV->UploadPath = "Applicants/".$this->Last_Name->CurrentValue.$this->First_Name->CurrentValue.$this->ID_Number->CurrentValue."/CV/";
            if (!EmptyValue($this->CV->Upload->DbValue)) {
                $this->CV->EditValue = $this->CV->Upload->DbValue;
            } else {
                $this->CV->EditValue = "";
            }
            if (!EmptyValue($this->CV->CurrentValue)) {
                $this->CV->Upload->FileName = $this->CV->CurrentValue;
            }
            if ($this->isShow() || $this->isCopy()) {
                RenderUploadField($this->CV);
            }

Try:

$this->CV->UploadPath = "Applicants/".$this->Last_Name->DbValue.$this->First_Name->DbValue.$this->ID_Number->DbValue."/CV/";

Changed it and I’m getting the same error/notice

You may read Field Setup → Edit Tags → File → Notes → #3 from PHPMaker Help menu as follows:The path can be dynamic. For example, if the upload path varies with some field value, you can refer to other fields by $this->MyField->DbValue.

However, you must be very careful when using dynamic folder, make sure the setting is valid as a folder name, i.e. it does not contain some characters which can not be used in a file path on your server. The setting will be evaluated to obtain the upload folder before the file is displayed and before the uploaded file is saved, so your setting should be consistent, do not use random number or current date/time to name the folder.

Alternatively, you can also use Row_Rendered, Row_Inserting and Row_Updating server events to set the field object’s UploadPath property.

Since everything is working I’m hiding all Notices. (I enable it back when I’m testing stuff)