check box/radio button error message PHP

General discussions related to php

Moderators: macek, egami, gesf

jarow
New php-forum User
New php-forum User
Posts: 7
Joined: Tue Jan 28, 2003 3:54 am

check box/radio button error message PHP

Postby jarow » Tue Jan 28, 2003 4:01 am

have created an add record form (.PHP) that has 3 checkboxes. The checked value = Y, the initial state is unchecked. The form is sent to go to a view page in which all the entered data is viewed.

When I preview the form in a browser and check all 3 boxes and submit the form works perfectly; that is the data is entered correctly into the mysql database and the view page becomes visible.

If I preview the form and leave any of the boxes unchecked I get the following error message:

PHP Notice: Undefined index: endemismo in c:\inetpub\wwwroot\fauna_europaea\TMP826889f9hy.php on line 37
PHP Warning: Cannot modify header information - headers already sent in c:\inetpub\wwwroot\fauna_europaea\TMP826889f9hy.php on line 47

endemismo in this case is the name of the checkbox left unchecked.

It might also be worthy noting that the data is entered correctly into the database despite the error message, that is if the check box is checked the corresponding database field receives a "Y" and is blank if not checked.

Any ideas how to fix the error message?

Many thanks

Jim

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Re: check box/radio button error message PHP

Postby Oleg Butuzov » Wed Jan 29, 2003 1:36 am

jarow wrote:have created an add record form (.PHP) that has 3 checkboxes. The checked value = Y, the initial state is unchecked. The form is sent to go to a view page in which all the entered data is viewed.

When I preview the form in a browser and check all 3 boxes and submit the form works perfectly; that is the data is entered correctly into the mysql database and the view page becomes visible.

If I preview the form and leave any of the boxes unchecked I get the following error message:

PHP Notice: Undefined index: endemismo in c:\inetpub\wwwroot\fauna_europaea\TMP826889f9hy.php on line 37
PHP Warning: Cannot modify header information - headers already sent in c:\inetpub\wwwroot\fauna_europaea\TMP826889f9hy.php on line 47

endemismo in this case is the name of the checkbox left unchecked.

It might also be worthy noting that the data is entered correctly into the database despite the error message, that is if the check box is checked the corresponding database field receives a "Y" and is blank if not checked.

Any ideas how to fix the error message?

Many thanks

Jim


PHP Notice: Undefined index: endemismo in c:\inetpub\wwwroot\fauna_europaea\TMP826889f9hy.php on line 37
PHP Warning: Cannot modify header information - headers already sent in c:\inetpub\wwwroot\fauna_europaea\TMP826889f9hy.php on line 47

headers alredy send... =)

you try to send headers whan php some print at the page

bad exemple

Code: Select all

<html></html>
<?
header ("Content-type: image/jpg");
header ("Cache-Control: no-cache, must-revalidate");
$img = imagecreatefrompng ($type);
$text_color = imagecolorallocate ($img, $r, $g, $b);
imagestring ($img, 2, 2, 1,  $dead, $text_color);
imagepng($img, '' , 100);
?>

User avatar
Redcircle
Moderator
Moderator
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Postby Redcircle » Fri Jan 31, 2003 2:09 am

PHP Notice: Undefined index: endemismo in c:\inetpub\wwwroot\fauna_europaea\TMP826889f9hy.php on line 37
PHP Warning: Cannot modify header information - headers already sent in c:\inetpub\wwwroot\fauna_europaea\TMP826889f9hy.php on line 47



The undifined index warning arises because the variable endemismo was never initialized.

to solve this use this on all posted variables

if(!isset($variable)) $variable='';

You get the header warning only because of the output the undefined index warning created


Return to “PHP General”

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest