Your question may be basic and simple, but that doesn’t mean the answer is simple or short…
There are a few ways to pass values to shader variables. The method depends on the type of shader variable. There are vertex variables (aka attributes), and per draw command variables (aka uniforms). For what you describe, you should use a shader uniform variable, because you are not describing something specific to any vertex.
The way you use different shaders, is the way you use any shader: you call glUseProgram(). If you want/need more than one shader, then write and compile and link each of them once. When you are ready to draw with one of them, call glUseProgram() to specify which you want to use. You can draw parts of a scene with one shader and other parts with another shader program. You can also draw some frames with one shader and other frames with another shader program.
You said you can find nowhere how to pass values to shader variables. Did you read the tutorial that I provided the link to?
I really think you need to study several tutorials and try to understand what they are doing. I don’t consider it wise to jump into programming without first having some understanding of what you are trying to do or how things work. Probably any introductory OpenGL shader language book would also be helpful for you.
Looking at your sample code, I can see no reason why you have a texture at all, or else why you have anything other than a texture. Ultimately, it looks like you are trying to assign a color based on the location within a triangle.
The sample code is a mechanism/idea, not correct code of course.
The mechanism/idea of your sample code made no sense and indicated a fundamental lack of understanding. That’s what my comment tactfully informed you of, of course.
Thanks for the amazing help…
I do hope you’re not being sarcastic…
I’m off to reading a shader book.
Great! Then you will be getting the help you need from an appropriate source. Who knows? Maybe once you’re an expert you’ll even come back here and provide amazing help for free to people just starting out.