Undefined index in form with checkbox

This is a discussion on Undefined index in form with checkbox within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I had a form working with a couple of checkboxes using the mail() function that takes the user to a ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-30-2003
socal local
 
Posts: n/a
Default Undefined index in form with checkbox

I had a form working with a couple of checkboxes using the mail()
function that takes the user to a simple "thanks for your input" page
using the header() function at the end. But, instead of this, I wanted
to be able to print the results of their input. So, after the mail()
part, I had replaced the header() part with print() but am getting this
error now for the box that was not checked.

Notice: Undefined index: bw in C:\wwwroot\test.php

Here is what I had working before I changed the header() to print():

$color = $_REQUEST['color'] ;
if($color == "on"){echo" CHECKED";}
$bw = $_REQUEST['bw'] ;
if($bw == "on"){echo" CHECKED";}




I'm a little new to PHP.

Reply With Quote
  #2 (permalink)  
Old 10-30-2003
socal local
 
Posts: n/a
Default Re: Undefined index in form with checkbox

socal local wrote:

> I had a form working with a couple of checkboxes using the mail()
> function that takes the user to a simple "thanks for your input" page
> using the header() function at the end. But, instead of this, I wanted
> to be able to print the results of their input. So, after the mail()
> part, I had replaced the header() part with print() but am getting this
> error now for the box that was not checked.
>
> Notice: Undefined index: bw in C:\wwwroot\test.php
>
> Here is what I had working before I changed the header() to print():
>
> $color = $_REQUEST['color'] ;
> if($color == "on"){echo" CHECKED";}
> $bw = $_REQUEST['bw'] ;
> if($bw == "on"){echo" CHECKED";}
>
>
>
>
> I'm a little new to PHP.
>


I fixed this by turning error_reporting in the php.ini file to Off.


Reply With Quote
  #3 (permalink)  
Old 11-01-2003
Janwillem Borleffs
 
Posts: n/a
Default Re: Undefined index in form with checkbox


"socal local" <coastin310@NoSpam.yahoo.com> schreef in bericht
news:jPcob.862970$Pk.131134@news.easynews.com...
> >
> > $color = $_REQUEST['color'] ;
> > if($color == "on"){echo" CHECKED";}
> > $bw = $_REQUEST['bw'] ;
> > if($bw == "on"){echo" CHECKED";}
> >

>
> I fixed this by turning error_reporting in the php.ini file to Off.
>


That is NOT a fix! Turn error_reporting on again and use
http://www.php.net/isset to see if the key exists.

Example:
if (isset($_REQUEST['bw']) && $_REQUEST['bw'] == "on"){echo" CHECKED";}


JW



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:10 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0