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? Quote Link to comment 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 Quote Link to comment 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']; } ?> Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
ryanhowdy Posted June 15, 2007 Author Share Posted June 15, 2007 thanks guys Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.