PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
radium35
Forum Commoner
Posts: 50 Joined: Mon Nov 10, 2008 5:05 pm
Location: USA
Contact:
Post
by radium35 » Tue Nov 11, 2008 4:07 pm
what am i doing wrong here? the script echo's all includes at the same time?
$a1=$_POST[first_name];
$a2=$_POST[last_name];
$a3=$_POST[work_phone];
$a4=$_POST[cell_phone];
$a5=$_POST[company];
$a6=$_POST[address];
$a7=$_POST[address_2];
$a8=$_POST[city];
$a9=$_POST[state];
$a10=$_POST[zip];
$a11=$_POST[email];
$a12=$_POST[sem_id];
$a13=$_POST[sem_title];
$a14=$_POST[sem_month];
$a15=$_POST[sem_day];
$a16=$_POST[sem_year];
$a17=$_POST[sem_time_hr];
$a18=$_POST[sem_time_min];
$a19=$_POST[sem_time_day];
$a20=$_POST[payment_type];
$paypalbutton = (include 'sem_paypalbutton.php');
$ccpayment = (include 'sem_ccpayment.php');
$checkpayment = (include 'sem_checkpayment.php');
switch ($a20) {
case "Pay Pal":
echo "$paypalbutton";
break;
case "Credit Card":
echo "$ccpayment";
break;
case "Check":
echo "$checkpayment";
break;
}
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Tue Nov 11, 2008 4:28 pm
Don't do the include until you need it.
Code: Select all
switch ($a20) {
case "Pay Pal":
include 'sem_paypalbutton.php'
break;
case "Credit Card":
include 'sem_ccpayment.php'
break;
case "Check":
include 'sem_checkpayment.php'
break;
}
Mark Baker
Forum Regular
Posts: 710 Joined: Thu Oct 30, 2008 6:24 pm
Post
by Mark Baker » Tue Nov 11, 2008 4:32 pm
Are there any echo or print statements inside your included files?
I'm assuming that it does have a return
radium35
Forum Commoner
Posts: 50 Joined: Mon Nov 10, 2008 5:05 pm
Location: USA
Contact:
Post
by radium35 » Tue Nov 11, 2008 4:39 pm
tasairis wrote: Don't do the include until you need it.
Code: Select all
switch ($a20) {
case "Pay Pal":
include 'sem_paypalbutton.php'
break;
case "Credit Card":
include 'sem_ccpayment.php'
break;
case "Check":
include 'sem_checkpayment.php'
break;
}
This worked perfect
thanks "tasairis"! glad it works don't understand why i can echo a variable with an include??
radium35
Forum Commoner
Posts: 50 Joined: Mon Nov 10, 2008 5:05 pm
Location: USA
Contact:
Post
by radium35 » Tue Nov 11, 2008 4:40 pm
Mark Baker wrote: Are there any echo or print statements inside your included files?
I'm assuming that it does have a return
ne, the include file has the payment information
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Tue Nov 11, 2008 4:45 pm
radium35 wrote: This worked perfect
thanks "tasairis"! glad it works don't understand why i can echo a variable with an include??
include isn't a function. It doesn't evaluate the file and return what it tried to print.
It just evaluates it.
You can do a couple other things if you know what you're doing, but it seems you weren't doing them.
radium35
Forum Commoner
Posts: 50 Joined: Mon Nov 10, 2008 5:05 pm
Location: USA
Contact:
Post
by radium35 » Tue Nov 11, 2008 4:46 pm
tasairis wrote: radium35 wrote: This worked perfect
thanks "tasairis"! glad it works don't understand why i can echo a variable with an include??
include isn't a function. It doesn't evaluate the file and return what it tried to print.
It just evaluates it.
You can do a couple other things if you know what you're doing, but it seems you weren't doing them.
umm... ok
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Tue Nov 11, 2008 5:01 pm
radium35 wrote: tasairis wrote: radium35 wrote: This worked perfect
thanks "tasairis"! glad it works don't understand why i can echo a variable with an include??
include isn't a function. It doesn't evaluate the file and return what it tried to print.
It just evaluates it.
You can do a couple other things if you know what you're doing, but it seems you weren't doing them.
umm... ok
Ever tried to do this?
Code: Select all
function test() {
echo "three";
}
$three = test();
echo "one plus two is " . $three;
It doesn't work the way you want for the exact same reason.
radium35
Forum Commoner
Posts: 50 Joined: Mon Nov 10, 2008 5:05 pm
Location: USA
Contact:
Post
by radium35 » Tue Nov 11, 2008 5:10 pm
ok, i get it. That makes sense now.