Jump to content

Form CHECKBOX Error


ded

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/153532-form-checkbox-error/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/153532-form-checkbox-error/#findComment-806723
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/153532-form-checkbox-error/#findComment-806739
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.