I have this command that i am calling from php (exec()):

openssl pkcs12 -export -in cert.pem -inkey key.pem -out cred.p12

and then i need to insert password twice
Enter Export Password:
Verifying - Enter Export Password:

I need script that will fill the password inputs, do you have any idea how should i do it?

Look at the Expect scripting language. Expect is an extension of the TCL scripting language. If your prefer, Python has the python expect module that you can use that is based on the Expect language.