Fix all issues with adding the url

@runchita20 I discovered several issues regarding adding the url.

I will comment inline the code what and why I have changed things.

If you try this it normally will work! 
Without this the record in the database won't have an id.