function free_seats($angebot_id) { $angebot = fetch_one_ride($angebot_id); $anzahl = $angebot['anzahl']; return $anzahl - count_mitfahrer($angebot_id); }
$angebot_id = $_POST['angebot_id']; $mf_name = $_POST['name']; $mf_tel = $_POST['tel']; $mf_email = $_POST['email']; $freie_plaetze = free_seats($angebot_id); if ($freie_plaetze > 0) { add_mitfahrer($angebot_id, $mf_name, $mf_tel, $mf_email); $mf_id = find_mitfahrer($angebot_id, $mf_email); if ($mf_id == 0) { //problem with database, return 2 echo 2; } else { //everything is ok return 0 echo 0; //everyone involved should get an email $angebot = fetch_one_ride($angebot_id); $f_name = $angebot['name']; $f_tel = $angebot['tel']; $f_email = $angebot['email']; $von = $angebot['von']; $nach = $angebot['nach']; $datum = show_date($angebot['time']); $zeit = show_time($angebot['time']); $treffpunkt = $angebot['treffpunkt']; $dtstart = make_dtcomponent($angebot['time']); $dtend = make_dtcomponent($angebot['time'] + 30 * 60); //duration 30 minutes $ics = make_ics($dtstart, $dtend, $treffpunkt, $von, $nach); $mitfahrer_msg = make_mitfahrer_message($mf_name, $von, $nach, $datum, $zeit, $f_name, $f_tel, $f_email); $subject = "Mitfahrgelegenheit ({$von} -> {$nach}) am {$datum}, {$zeit}"; $from = "*****@*****.**";