ryanhowdy Posted June 15, 2007 Share Posted June 15, 2007 PHP Notice: Undefined index: user in /var/www/vhosts/mydomain.com/httpdocs/v3/index.php on line 3 line 3 looks like this... $user = $_POST['user']; This is a login script, and I'm checking to see if the username field was submitted and filled out. the code works fine, but I want to try and clean up these notices. what is the correct way to check for this? without the notices? Link to comment https://forums.phpfreaks.com/topic/55744-php-notice/ Share on other sites More sharing options...
MrSheen Posted June 15, 2007 Share Posted June 15, 2007 Easist way to get rid of notices, is to turn them off Link to comment https://forums.phpfreaks.com/topic/55744-php-notice/#findComment-275401 Share on other sites More sharing options...
Dragen Posted June 15, 2007 Share Posted June 15, 2007 use this code: <?php if(isset($_POST['user'])){ $user = $_POST['user']; } ?> Link to comment https://forums.phpfreaks.com/topic/55744-php-notice/#findComment-275403 Share on other sites More sharing options...
per1os Posted June 15, 2007 Share Posted June 15, 2007 or a bit nicer looking <?php $user = isset($_POST['user'])?$_POST['user']:''; ?> That way later on if you use $user, it is defined either way. Link to comment https://forums.phpfreaks.com/topic/55744-php-notice/#findComment-275409 Share on other sites More sharing options...
ryanhowdy Posted June 15, 2007 Author Share Posted June 15, 2007 thanks guys Link to comment https://forums.phpfreaks.com/topic/55744-php-notice/#findComment-275416 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.