Re: [PHP] Switch syntax From: Jon Farmer (jonfarmer <email protected>)
Date: 10/15/01

The problemn is with the bank_details function. The $Payment variable does
not have global scope Either give it global scope or pass the value of the
variable through when calling the function

eg

function bank_details($Payment) {

        //function code

}

and call it as

bank_details($Payment);

Regards

jon

--
Jon Farmer
Systems Programmer, Entanet www.enta.net
Tel 01952 428969 Mob 07763 620378
PGP Key available, send blank email to pgpkey <email protected>

----- Original Message ----- From: "Rudi Ahlers" <kopspier <email protected>> To: "PHP General" <php-general <email protected>> Sent: Monday, October 15, 2001 12:54 PM Subject: [PHP] Switch syntax

> Hi > > I wonder if this is possible, and if it is, what am I doing wrong? I got a > form, with either debit order details, or credit card details, both on the > same form. But I have put the select box, the debit order form, and the > credit card form in one file, and then users select it with an if statement, > and it's then called with functions. This all works very well with: > if ($Payment = 'Debit') { > debit(); > } elseif ($Payment = 'Credit') { > credit(); > } else { > select(); > > > Now, I email the form to sales department, but I want the output to differ, > depending on whether they selected debit order or credit card. I tried the > following, bit it didn't seem to work. > > > function bank_details() > { > switch ($Payment) { > case "Debit": > debitorder(); > break; > case "Credit"; > creditcard(); > break; > } > > function debitorder() > { > $bank_details = "AccountHolders Name: $account_holders_name\n"; > $bank_details .= "Account Number: $account_number\n"; > $bank_details .= "Bank Name: $bank_name\n"; > $bank_details .= "Branch Name: $Branch_name\n"; > $bank_details .= "Branch Number: $branch_number\n"; > $bank_details .= "Branch Number: $branch_number\n"; > } > > function creditcard() > { > $bank_details = "Card Holder: $CardHolder\n"; > $bank_details .= "Card Number: $CardNumber\n"; > $bank_details .= "CvvNumber: $CvvNumber\n"; > $bank_details .= "CardType: $CardType\n"; > $bank_details .= "CardMonth: $CardMonth\n"; > $bank_details .= "CardYear: $CardYear\n"; > } > } > > I call bank_details() as follows: > > $content .="Firstname: $first_name\n > Lastname: $last_name\n > ID Number: $your_id_number\n > Company Name: $company\n > Postal Address: $postal_address_1\n > Postal Address2: $postal_address_2\n > Postal code: $postal_code\n > Email: $email\n > Work Phone: $work_phone_number\n > Work Code: $work_phone_number_code\n > Home Phone: $phone_home\n > Home Code: $phone_home_code\n > Faxn Nmber: $fax_number\n > Fax Code: $fax_number_code\n > Cell: $phone_cell\n > Domain Name: $domain_name\n > Hosting Option: $Hosting_option\n > Upload Option: $Upload_option\n > Application Description: $ApplicationDesc\n > $bank_details > $reseller > Agreed: $agreed_with_the_terms_and_conditions\n"; > > It doesn't seem to display the bank detail though, on either form. Is there > anyway of getting this done? > > > Regards > Rudi Ahlers > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe <email protected> > For additional commands, e-mail: php-general-help <email protected> > To contact the list administrators, e-mail: php-list-admin <email protected> >

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>