chadrt Posted January 16, 2013 Share Posted January 16, 2013 I have this line of code that reads like this: $theusername = $_POST['username']; if(empty($theusername)){ header("Location: login.php?error=allfields"); } I have tried to put $_POST['username'] within the empty but either way it doesnt redirect to that it just continues to execute code in the page. The result should be back to the index.php where the login is located and then because of the error field it shows a custom message to the user. No there is no other output to the browser Yes it continues to execute code from the rest of the system No I do not see the url in the address box of the browser showing the correct url Quote Link to comment https://forums.phpfreaks.com/topic/273222-trying-to-redirect-on-empy/ Share on other sites More sharing options...
QuickOldCar Posted January 16, 2013 Share Posted January 16, 2013 (edited) try this $theusername = trim($_POST['username']); if(isset($_POST['username']) && $theusername == '' ){ header("Location: login.php?error=allfields"); die(); } Edited January 16, 2013 by QuickOldCar Quote Link to comment https://forums.phpfreaks.com/topic/273222-trying-to-redirect-on-empy/#findComment-1406028 Share on other sites More sharing options...
QuickOldCar Posted January 16, 2013 Share Posted January 16, 2013 or this $theusername = trim($_POST['username']); if(isset($_POST['username']) && $theusername == '' ){ die(header("Location: login.php?error=allfields")); } same thing, just one less line Quote Link to comment https://forums.phpfreaks.com/topic/273222-trying-to-redirect-on-empy/#findComment-1406030 Share on other sites More sharing options...
chadrt Posted January 16, 2013 Author Share Posted January 16, 2013 That worked so much better! I have followed a few tutorials on different sites to come up what I had there and nothing worked. After looking up the "trim" at php I see how that works. Thank you!! Quote Link to comment https://forums.phpfreaks.com/topic/273222-trying-to-redirect-on-empy/#findComment-1406035 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.