The parameters of your stored procedure do not seem to reflect your needs, therefore some assumptions are necessary.
CREATE PROCEDURE geodist (IN userid int, IN dist int) BEGIN
I cannot provide the complete solution in one posting because in the abstract relation p->q->r->s, and if you write p->g then q->r->s is logically invalidated.
As a result your one table with auto incremented id, latitude, and longitude comes under scrutiny. The only question I would pose is what exactly does this three field table represent? Rationally the answer is it represents all locations as (lon,lat) pairs.
Given userid, you then select your anchor point A(lon.lat), from the table users5.
-- get the original lon and lat for the userid
select longitude, latitude into mylon, mylat
users5 where id=userid limit 1;
interlude:: From an anchored point you can go East,West.North,South, which when flattened is rectangular as you calculate:
-- calculate lon and lat for the rectangle:
set lon1 = mylon-dist/abs(cos(radians(mylat))*69);
set lon2 = mylon+dist/abs(cos(radians(mylat))*69);
set lat1 = mylat-(dist/69);
set lat2 = mylat+(dist/69);
I would hope your calculations are correct.
At this point you have two ranges, one each for lattitude and longitude, therefore the pairs to select from your table users5, within the radius, dist, must be betweem (lon1 and lon2) and (lat1 and lat2). The query can now proceed without calculations within it...