Fix undefined index

I fixed several undefined index and undefined variable PHP notices.