I would like to know if we can connect esp8266 module ornodemcu to a network without giving the ssid and pasword in the code? if yes, please help how to do it
You could put the values in EEPROM.
You could make the password a hashed version of the SSID and scan for networks on start-up. For each SSID found, hash the SSID and try that for a password.
Or you could save it to the SPIFFS.
Take a look at the WiFi Manager library.
It allows you to select a network to connect to, saves the settings, and automatically starts an AP when it can't connect. You can then connect to the ESP directly (using a smart phone or laptop) to change the WiFi settings.
The ESP will still have the latest SSID and password saved when you upload a new sketch without the login. Try it, your esp will still connect with the login from the old sketch.
WiFi Manager works great.
If no stored values, it'll start a WiFi host, allowing you to connect with any WiFi device (such as a smartphone) and provide the required info.
If stored values, it'll try to connect. If fail, start the WiFi host mode as before.