nathansizemore Posted May 1, 2012 Share Posted May 1, 2012 Hello, I am trying to implement error proofing to a log in script. But, I cannot get it to work? I have no idea what is going on, or why it doesn't work like I expect it to. I have tried everything, please advise. This is the method I am calling: public function i_exist($this_username) { //$host_array = null; //$host_array = $this->collection->findOne(array("Username" => $this_username)); //if ($host_array['Username'] = $this_username) //{ return true; //} //return false; } This is where I am calling it: if (!empty($_POST['Username'])) { $host = new Host(); $event = new Event(); if ($host->i_exist($_POST['Username'])) { header("Location: http://www.drink-social.com/error.php?login=duplicate"); } It is supposed to check the database and see if that username is already in use. But it never directs to the error page? I have even tried commenting everything out and returning true, and returning 1. Nothing? Any advice? Quote Link to comment https://forums.phpfreaks.com/topic/261874-help-returning-boolean/ Share on other sites More sharing options...
marcus Posted May 1, 2012 Share Posted May 1, 2012 Is $this->collection->findOne(array("Username" => $this_username)) supposed to be returning a username, or an object? Quote Link to comment https://forums.phpfreaks.com/topic/261874-help-returning-boolean/#findComment-1341829 Share on other sites More sharing options...
nathansizemore Posted May 1, 2012 Author Share Posted May 1, 2012 Returns an object. Quote Link to comment https://forums.phpfreaks.com/topic/261874-help-returning-boolean/#findComment-1341830 Share on other sites More sharing options...
marcus Posted May 1, 2012 Share Posted May 1, 2012 Ok, well in your if statement you're doing an assignment, not a comparison. if($a = $b) is not the same as if($a == $b) Quote Link to comment https://forums.phpfreaks.com/topic/261874-help-returning-boolean/#findComment-1341834 Share on other sites More sharing options...
nathansizemore Posted May 1, 2012 Author Share Posted May 1, 2012 Doh! Aside from that slip-up, any idea why it isn't working in the current state of simply, return true;? Quote Link to comment https://forums.phpfreaks.com/topic/261874-help-returning-boolean/#findComment-1341837 Share on other sites More sharing options...
nathansizemore Posted May 1, 2012 Author Share Posted May 1, 2012 Found it. I didn't have the code below wrapped in an else statement, so it directed to that page, but then continued to execute to another page. Quote Link to comment https://forums.phpfreaks.com/topic/261874-help-returning-boolean/#findComment-1341840 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.