neeep Posted January 15, 2010 Share Posted January 15, 2010 if (!isset($_POST['invoiceemployer']) && !isset($_POST['lodging'])){ && !isset($_POST['draft'])){ echo "<span id='red'><font size='4'> Please pick invoice employer, Lodging or Draft:</font><br />$error</span>"; } else { // now you need to figure out which one they clicked.. if (isset($_POST['invoiceemployer'])) { // invoiceemployer day was selected } else { if (isset($_POST['lodging'])) { //lodging was selected }else } } This isnt being accepted. It was working fine until I added the third option of draft. My page wont load and I get this error... syntax error, unexpected T_BOOLEAN_AND Any code suggestions? thanks. Quote Link to comment Share on other sites More sharing options...
Buddski Posted January 15, 2010 Share Posted January 15, 2010 Your first line is a bit screwy. if (!isset($_POST['invoiceemployer']) && !isset($_POST['lodging'])){ && !isset($_POST['draft'])){ should be if (!isset($_POST['invoiceemployer']) && !isset($_POST['lodging']) && !isset($_POST['draft'])) { Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted January 15, 2010 Share Posted January 15, 2010 Try this: if (!isset($_POST['invoiceemployer']) && !isset($_POST['lodging']) && !isset($_POST['draft']))){ Quote Link to comment Share on other sites More sharing options...
neeep Posted January 15, 2010 Author Share Posted January 15, 2010 Thanks, I can't believe I didn't see that. I assumed the problem was bigger than just a stray bracket! http://pastebin.com/m67818aba here is my code..Im getting this weird error Parse error: syntax error, unexpected $end in /public_html/kenny/form.php on line 518 I can't make sense of it. Can anyone see the problem? Quote Link to comment Share on other sites More sharing options...
Buddski Posted January 15, 2010 Share Posted January 15, 2010 Try this as your code block.. I did a few corrections if (!isset($_POST['invoiceemployer']) && !isset($_POST['lodging']) && !isset($_POST['draft'])){ echo "<span id='red'><font size='4'> Please pick invoice employer, Lodging or Draft:</font><br />$error</span>"; } else { // now you need to figure out which one they clicked.. if (isset($_POST['invoiceemployer'])) { // invoiceemployer day was selected } elseif (isset($_POST['lodging'])) { //lodging was selected } else { } } Do you only want 1 of them selected at any one time? or can they choose more than 1? If they can only choose 1 you should use radio buttons and we can make this code alot smaller Quote Link to comment Share on other sites More sharing options...
neeep Posted January 15, 2010 Author Share Posted January 15, 2010 Its fine now, I just needed a bracket somewhere, thanks. Quote Link to comment Share on other sites More sharing options...
neeep Posted January 15, 2010 Author Share Posted January 15, 2010 Ya, they only choose one. I was happy to just have this working though. I am such a beginner that I take what I can get! Quote Link to comment Share on other sites More sharing options...
Buddski Posted January 15, 2010 Share Posted January 15, 2010 Well for the sake of learning ill give you a little snippet of a radio usage HTML <input type="radio" name="thebox" id="invoiceemployer" value="invoiceemployer" /> <input type="radio" name="thebox" id="draft" value="draft" /> <input type="radio" name="thebox" id="lodging" value="lodging" /> then in PHP after the form is posted you can do this.. if (isset($_POST['thebox'])) { echo 'The selected radio was: '.$_POST['thebox']; } else { echo "<span id='red'><font size='4'> Please pick invoice employer, Lodging or Draft:</font><br />$error</span>"; } Simple huh? Quote Link to comment Share on other sites More sharing options...
neeep Posted January 15, 2010 Author Share Posted January 15, 2010 http://pastebin.com/m328ff01e There's my code. The relevant stuff is at 133-137 and 386-396 The radio buttons arent working. as you can see at the bottom of this page.. http://www.fishpondmedia.com/kenny/form.php can you see what's wrong? Quote Link to comment Share on other sites More sharing options...
Buddski Posted January 15, 2010 Share Posted January 15, 2010 The 'name' attributes on your radio buttons must be the same.. Something like 'payment' would be appropriate.. Then for each of the radios you need to set the 'value' to what is it.. at the moment you have the name as the value Once you have changed the name to 'payment' your php will check thast with if (isset($_POST['payment'])) { } else { } Quote Link to comment Share on other sites More sharing options...
neeep Posted January 15, 2010 Author Share Posted January 15, 2010 http://pastebin.com/mbbf8cfc The radio buttons work, but there is no indication in the email that one has been checked..can you see why? Quote Link to comment Share on other sites More sharing options...
Buddski Posted January 15, 2010 Share Posted January 15, 2010 You should only build your email message AFTER you have validated the inputs.. These $emailMessage .= "\ninvoice employer: " . (isset($_POST['invoiceemployer'])); $emailMessage .= "\nlodging: " . (isset($_POST['lodging'])); $emailMessage .= "\ndraft: " . (isset($_POST['draft'])); are not there anymore you can make it more appropriate and put $emailMessage .= "\nPayment Type: ".$_POST['payment']; but definitely validate your form values first.. its just better coding practice.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.