Arduino setup not working

watford98:
the motor however spins even when there is any sort of wire in the port.

This is a bad idea (leaving the wire act as an antenna).

Try first by:

Tying the inputs to 0 or 5 volts directly.

programming input with "INPUT PULLUP".

Regards