galdikas Posted May 13, 2011 Share Posted May 13, 2011 <form action='bank.php' method='post'> Amount to invest:<input type='text' name='investment' value='{$bi['money']}'/> For:<select name='period'>"; $ibank=mysql_query("SELECT * FROM ibank"); while($ib=mysql_fetch_assoc($ibank)) { echo"<option value='{$ib['id']}'>{$ib['name']}({$ib['rate']}%)</option>"; } echo"</select> <input type='submit' name='submit' value='Invest' /> </form> ok... Can anyone tell me why when I click Invest button, it redirects me to gym.php???? Form looks alright to me... There is no other code that would accept the form. But even without that code, should't it just refresh the same page??? Quote Link to comment Share on other sites More sharing options...
Analog Posted May 13, 2011 Share Posted May 13, 2011 Without seeing the rest of the file the only thing I can come up with is maybe there is a form above that with an action to call gym.php Quote Link to comment Share on other sites More sharing options...
lucky3809 Posted May 13, 2011 Share Posted May 13, 2011 Well your query is wrong how is it going to determine what user you are? You have it selecting from Everyones ibank... As for it redirecting you to the gym, it has nothing to do with that bit of code... Quote Link to comment Share on other sites More sharing options...
Dayo Posted May 13, 2011 Share Posted May 13, 2011 have you got a open form before hand, try adding </form> before you start your bank.php form (this is a quick fix but you should find where it originates from and close the tag properly. And as said before you are selecting everything from ibank a better query would be SELECT `id`, `name`, `rate` FROM `ibank` WHERE `.....`='......' (fill in the dots with the userid fields) Quote Link to comment Share on other sites More sharing options...
Analog Posted May 13, 2011 Share Posted May 13, 2011 I assumed ibank is storing info on how long the investment can be.. (ie 1 week at 2% interest, 2 weeks at 4.5%, etc....) Quote Link to comment Share on other sites More sharing options...
galdikas Posted May 13, 2011 Author Share Posted May 13, 2011 (edited) Yeah, I bank just stores the length, rate, and timespan of investment :) So I need to select everything... And it is only 4 rows there, so not a major thing anywayy :) I found the problem.. It was as Dayo said... another form left open above :) Was half asleep yesterday :) Edited May 13, 2011 by galdikas Quote Link to comment Share on other sites More sharing options...
Dominion Posted May 13, 2011 Share Posted May 13, 2011 <div id="main"> <form action="gym.php" method="post"> I just used ctrl+f to look for "gym.php" (line 28) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.