Great question. First of all, the second sentence is correct.
Here two simple sentences are joined with the word “and”, to form a Compound Sentence.
The first part is talking about a past event, i,e. you went somewhere
and the second part is also talking about a past fact i.e. you forgot to eat.
So if you take the first part and make it simple past then the form would be
You went there.
Now write it as a question and it would become
Did you go there?
Similarly, the second part is simple past tense, and the full sentence would be
You forgot to eat.
So the two sentences in the simple past tense are
- Did you go there?
- You forgot to eat.
If we join them with the word “and” to form a compound sentence it becomes
Did you go there and forgot to eat?
Coming back to the other part of your question
“whether the "Did" still "has effect" in the second half of the question,”
The situation is, there are two past events, one happened before the other. Here the event “going” happened first, and the event “forgetting” happened after that and both events happened in the past.
- Had you gone there?
- Had you forgotten to eat?
So the sentence would be like this if you take “Had you” in common for the two events.
Had you gone there, and forgotten to eat?
Here both events bear a sense of completion. So they are in past perfect tense instead of past tense.
But if You consider the two events as a sequence of events. The first event “going” is past perfect tense and the second event “forgetting” is simple past tense. Then the sentence would be
You had gone there and forgot to eat.
So the sentence as a question would be
Had you gone there, and you forgot to eat?