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 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 try this $theusername = trim($_POST['username']); if(isset($_POST['username']) && $theusername == '' ){ header("Location: login.php?error=allfields"); die(); } 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 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!! 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
Archived
This topic is now archived and is closed to further replies.