Forum Moderators: coopster

Message Too Old, No Replies

Posting Error

Posting error with checkboxes on web form

         

rosco400

12:48 am on Jul 3, 2005 (gmt 0)

10+ Year Member



Hi there,

I am getting a peculiar error with checkboxes on my web form. The error that appears is:

Notice: Undefined index in chkOther...

Code for checkbox in the form:
<INPUT type="CheckBox" value="Other" Name="chkOther">

Scripting code for posting:
if ($_POST['chkOther'])
{$msg = $msg."\n".($_POST['chkOther']);}

Any help would be greatly appreciated.

jatar_k

3:03 am on Jul 3, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld rosco400,

it is because you aren't testing whether it is set, you are testing the value of it, therefore if it isn't set it returns a notice.

It should be fixed by changing your if

if ($_POST['chkOther'])

to

if (isset($_POST['chkOther']))

rosco400

5:22 am on Jul 3, 2005 (gmt 0)

10+ Year Member



Thanks heaps.

You have solved my problem.

Ross.