Which computer should I buy for gaming?

They both have 512mb video cards i'll TRY to use for gaming.
Geforce 310 or ATI HD 4350 are pretty miserable gaming cards. Both are entry level video cards best suited to home entertainment PCs.
Of the 2 the HD 4350 is the better video card. But the HP also has a 250W PSU so for a gaming solution you'll need a new power supply and a video card.
THG Graphics Card Hierarchy Chart Geforce 310 - 8 steps above the bottom. HD 4350 3 steps higher. You probably want something no lower than 8 steps from the top.
The Lenovo has a slightly better CPU. The C2D E7500 2.93Ghz CPU is a notch better than the Athlon II X2 250 3.0Ghz CPU.

Both Lenovo H230 and HP 4302 are a generation out of date and no longer sold on the Lenovo or HP websites.

You'd be a lot better off buying a HP Pavilion p6570t off the HP website for $550. Core i3 530 3.06Ghz CPU
or HP Pavilion p6550z for $470 with Athlon II X2 250 3.0Ghz CPU upgrade.