Issues regarding form

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Re: Issues regarding form

Post by seandisanti » Sun Apr 20, 2014 11:48 pm

It's your condition, isset($_POST['Submit']) will only return true or false, but you are looking for !=4 which would mean every possible result

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Re: Issues regarding form

Post by seandisanti » Mon Apr 21, 2014 11:39 pm

Assuming you are ok with 5 of any type of ticket, the first thing you need to do is to count your tickets. I would handle the count something like:

Code: Select all

$count = 0
foreach ($post as $key=>$value){
     if (preg_match ('/Adult|Adult_Express|Youth|Senior/',$key) && is_numeric($value)){
          $count += $value;
}
}
$discount = ($count>=5)?.05:0;

// code to figure total of tickets would go here

if ($discount){
     echo 'For buying ' . $count . ' tickets with us today you received a 5% discount of ' . round($discount * $total,2);
     $total -= $total * $discount;
}

 
I just typed that up without testing it, but barring any typos it should work

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests