ded Posted April 10, 2009 Share Posted April 10, 2009 I know this is probably a simple fix. I have 4 checkboxs on the form: <input name="chalking" type="checkbox" value="Y" /> Chalking<br /> <input name="setup" type="checkbox" value="Y" /> Monday Setup Crew<br /> <input name="teardown" type="checkbox" value="Y" /> Sunday Tear Down Crew<br /> <input name="ticketbooth" type="checkbox" value="Y" /> Ticket/Booth If I check all 4 boxes, the post.php works fine. If I check anything less, if receive an error. Notice: Undefined index: chalking in /home1/website/public_html/web/help/postindiv.php on line 10 Notice: Undefined index: ticketbooth in /home1/website/public_html/web/help/postindiv.php on line 13 $chalking = $_POST['chalking']; $setup = $_POST['setup']; $teardown = $_POST['teardown']; $ticketbooth = $_POST['ticketbooth']; Any ideas? Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 10, 2009 Share Posted April 10, 2009 You've got strict mode enabled - nothing to worry about. You can suppress the notice by using this: $chalking = @$_POST['chalking']; Or redefine error reporting using this: error_reporting(E_ALL ^ E_NOTICE); That will allow error messages to get through but disable those notices. That notice you're getting just means you're checking something before it has been defined. In this case $_POST['chalking'] (and the other one) won't always be defined. Quote Link to comment Share on other sites More sharing options...
AdRock Posted April 10, 2009 Share Posted April 10, 2009 Beaten again Or you could use if(isset($_POST['chalking'])) $chalking = $_POST['chalking']; etc Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 10, 2009 Share Posted April 10, 2009 AdRock's is probably the best solution. Quote Link to comment Share on other sites More sharing options...
Omzy Posted April 10, 2009 Share Posted April 10, 2009 Does the '@' symbol just supress the message, or does it perform the same function as the isset()? Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted April 10, 2009 Share Posted April 10, 2009 Does the '@' symbol just supress the message, or does it perform the same function as the isset()? suppresses the error message. Quote Link to comment Share on other sites More sharing options...
laffin Posted April 10, 2009 Share Posted April 10, 2009 I prefer to use AdRocks suggestion. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 10, 2009 Share Posted April 10, 2009 @ should be used with care. I rarely use it anywhere other than on $_POST or $_GET at the start of a form (that generate annoying notices) otherwise you can be hiding error messages that need to be seen. Each to their own way of coding Quote Link to comment Share on other sites More sharing options...
Omzy Posted April 10, 2009 Share Posted April 10, 2009 Well basically on one of my contact forms I have: @mail($to,$subject,$message,$headers); I have this because I usually test on my localhost machine, which does not have an smtp function. Without the @ symbol I was getting the error message on screen, so I put the @ symbol in as I thought it was used to check if there is a mail server present. But it's clear now, it's still trying to send the message but just not displaying the error anymore... how can I tell it not to try and send an email if there is no mail server defiined? Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 10, 2009 Share Posted April 10, 2009 mail() returns boolean - true on success, false on error so you can do this: if (@mail($a,$b,$c,$d)) { //it worked! } else { //failed } Quote Link to comment Share on other sites More sharing options...
laffin Posted April 10, 2009 Share Posted April 10, 2009 or as he asked check the ini <?php if(!empty(ini_get('smtp')) mail($a,$b,$c,$d); this means just see if smtp php.ini variable is not empty but again this can also be 'sendmail_path' for linux systems Quote Link to comment Share on other sites More sharing options...
Omzy Posted April 10, 2009 Share Posted April 10, 2009 thanks guys i'll hav a play around with it 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.