View Full Version : Sending Email and radio buttons.

08-25-2006, 03:33 PM
Ok, so now my script is preforming to par except for one thing. It's supposed to send e-mail to the admin and the person registering. When the Payment option is 'PayPal' Checked, the e-mail doesn't send. if 'cheque' is chwcked, the e-mail sends, curious... I never put in any conditionals that ever question whether an e-mail should be sent or not as it gets sent right before you see the Payment Page and by this point everything should be ok. Why would this be happening?

Code can be seen at:


html form can be seen at:


txt version of php script can be seen at:


Thanks for any help,

08-25-2006, 07:17 PM
I copied your code to my own test site and tried it-- worked for me with both paypal and cheque. So I dunno why you'd be having a problem.

Just an FYI, you can print an entire array using the print_r() function, instead of listing every variable in the array (as you've done in your Debug function). You can just do print_r($_POST). You should use the <pre> tag to make it readable.

print "<PRE>\n";
print "</PRE>\n";

One more FYI, you can use a loop to copy the $_POST array to the $_SESSION array, instead of doing each array element separately.

foreach ($_POST as $pKey => $pVal) {
$_SESSION[$pKey] = $pVal;

And one more nag for you :)... it's bad practice to code associative array elements without using quotes. For example, $_SESSION[PaymentType] is not good; even though it works, you should use $_SESSION['PaymentType'] instead. The PHP manual explains what the difference is and why this is important. Here's the link (http://www.php.net/manual/en/language.types.array.php). (Look for the section titled "Array do's and dont's".)

08-25-2006, 10:47 PM
I really don't understand what's going on here... I tried to change the radio buttons to a dropdown and now I don't get any mail at all... What could be causing this... I don't understand... Any other Ideas...

08-26-2006, 12:12 AM
It's not your code... like I said it worked for me. Perhaps you should look into your PHP configuration and make sure it's ok.

08-26-2006, 11:26 AM
I did a little more investigating, and I found that when I commented out this line:

$headers = 'MIME-Version: 1.0' . "\n";

The mail sends fine, if I uncomment it, it doesn't send the e-mail when the paypal option is selected...

Do you know why this line would have anything to do with the mail not being sent?

08-26-2006, 05:02 PM
I'm not smart about email types and mime types and server configs etc.. that's where it seems your problem lies. Is your PHP on a windows or a unix/linix machine? The PHP manual suggests there are significant differences between the two when it comes to email.

You may want to revert to plain text email to make sure it works 100% of the time.

I really don't see how the radio button has anything to do with the success of sending the email.

Can you find the email logs? There may be error messages in there that can give you a clue what's going on.

08-26-2006, 06:01 PM
I really don't see how the radio button has anything to do with the success of sending the email.

I do. If the mail was bordering on being cast as spam by a spam checker, making the email 100% HTML would likely push it over the limit. Pure HTML emails get penalized by spam checkers. You should try to make your emails multipart so that they have a plain text part too. Just make sure the plain text part has the same content as the HTML part... spam checkers do check this too.

If you need a way to make multipart emails you can use the library in my signature, or there are other classes out there... but not as good :P (PHPMailer is the one people were previously using, but it hogs resources and runs slowly as well as not implementing a lot of SMTP stuff. The Symfony project are to replace PHPMailer with Swift Mailer).

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum