Re: reason for a "Notice:.." on one site but not another? (Same code.)
| From: | Mari Masuda | Date: | Sun, 09 Aug 2009 23:53:58 +0000 |
| Subject: | Re: reason for a "Notice:.." on one site but not another? (Same code.) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-296532@lists.php.net to get a copy of this message | ||
On Aug 9, 2009, at 16:43, John Butler wrote:
Hi sunday coders, I've been using this kind of logic on one PHP site I work on to display one thing or another depending on whether the form was submitted or not: if($_POST['UserWishesDateRange']) { //--line 79 echo'submitted'; } else { echo'NOT submitted'; } and it works great on that site. But on another site it still works, but gives this error: Notice: Undefined index: UserWishesDateRange in /home/vs/site/phvs/bl/7solarsecrets/admin/trackingcode.html on line 79 I assume that is because the error display settings are set to a more rigorous level in this latter site. Is this correct? (Both sites reside on servers where I am not the admin.) ------------ John Butler (Govinda) govinda.webdnatalk@gmail.comYou could do something like: if(isset($_POST['UserWishesDateRange'])) { //--line 79 or you could use something like !empty($_POST['UserWishesDateRange']) echo 'submitted'; } else { echo 'NOT submitted'; } This will check if $_POST['UserWishesDateRange'] is set to something. You are getting the error message because $_POST['UserWishesDateRange'] is not set if the form is not submitted. The server where you don't get the error message probably just has error reporting turned off.