Jump to content

Submit Form


corkg

Recommended Posts

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.