Help me in collecting data from 5 html pages and store variable in one PHP file and mail it

I tried my best to collect data from 5 HTML pages in one PHP file and send it as a mail… but I failed.

I succeed in sending mail from one HTML by file storing data in PHP. But whenever I connect the same PHP file to multiple HTML pages. It’s throwing undefined index error. Sometimes blank mail is sending.
The variables are not holding data. I dumped data by put_file_contents for each if it was storing data. But it is not holding last for the last moment until the mail function.

I need serious help. My head is shaking.

My Github project link is - Multipage form

For One Page, Mail is working perfectly, Screenshot Attached-
https://paste.ubuntu.com/p/hDbHvgrs82/ -2nd link

After connecting multiple HTML pages with one PHP file, if I declare all variables as global -
same Pastebin link - 1st link

and if I remove “global” variable declaring, it throws index error.