help connecting Arduino UNO to n-ch MOSFET via Optocoupler

Thank you for explanation.
Sorry it took me so long to answer, I have been very busy and did not have much time for this project. Now I have assembled this:

But I still got problems: To test the circuit before I connect Arduino to it, I connected a 5V power supply where Arduino pins should be. It activated the motors, but when I disconnected, the motors were still on. They were also still on if I disconnected the main power and then reconnected it. Only after disconnecting the MOSFETs from Optocouplers did the solenoids return to off-state. Im probably missing something important that I do not see because Im a newb. I again ask for your help!

PS: I know that I should put separate resistors for each OC, but they will not be all online at the same time.

Thank you!