corkg Posted July 22, 2007 Share Posted July 22, 2007 Hi I have this code and when i put the amount of tickets you buy and hit Return it does not submit and there is no change to the database, yet when you hit the submit button it works. if(strip_tags($_POST['Submit']) && strip_tags($_POST['amount'])){ $amount = (strip_tags($_POST['amount'])); if ($amount == 0 || !$amount || ereg('[^0-9]',$amount)){ print "You cant buy that amount."; }elseif ($amount != 0 || $amount || !ereg('[^0-9]',$amount)){ $cost= $lotto_inf->price * $amount; if ($cost > $fetch->money){ echo "You dont have enough money"; }elseif ($cost <= $fetch->money){ $number=$amount; $current = 0; while ($current < $number) { mysql_query("INSERT INTO `lotto` (`id`, `owner`) VALUES ('', '$username');"); $current++; } mysql_query("UPDATE lotto_info SET jackpot=jackpot+$cost WHERE id='1'"); mysql_query("UPDATE users SET money=money-$cost WHERE username='$username'"); echo "$amount tickets bought"; } }} ?> <tr> <td class=news>Buy tickets:</td> <td class=news><form action="" name="form1" method="post" ><input name="amount" class="text" type="text" id="amount" size="15" maxlength="4"></input> <input name="Submit" type="submit" id="Submit" value="Submit"></input></form> Quote Link to comment Share on other sites More sharing options...
jvrothjr Posted July 22, 2007 Share Posted July 22, 2007 disable the enter key so they have to select submit echo "<INPUT TYPE=TEXT NAME=TxtSearch onKeyDown='if(event.keyCode==13){return false};' value=''></P>"; Quote Link to comment Share on other sites More sharing options...
corkg Posted July 22, 2007 Author Share Posted July 22, 2007 Thanks, But I would like it if they could just push return to make it easier for them. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 22, 2007 Share Posted July 22, 2007 If you google submitting a form on enter you'll find the necessary javascript. Quote Link to comment Share on other sites More sharing options...
corkg Posted July 22, 2007 Author Share Posted July 22, 2007 I have tryed that but it has not worked is it something to do with the php code that saves the info, because it reloads the window. Quote Link to comment Share on other sites More sharing options...
corkg Posted July 22, 2007 Author Share Posted July 22, 2007 I have got it working I got rid of the if( strip_tags($_POST['Submit'])) bit 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.