TGWSE_GY Posted April 14, 2009 Share Posted April 14, 2009 Hi guys, I am trying to add a feature to my login system so that if the user has not confirmed their email address with the confirmation code that was sent to them it denies the access. On the login table I have a column names MemStat I am wanting to test if it says NoConf if it does they are denied access until they confirm their email address. <?php /* @author George Young @copyright 2008 This script is ment for a high security login system using advance algorythmic verification. */ // Call database connection info include('config.php'); // Setting variable $con to hold the login information for the mysql server $con = mysql_connect($Host, $Login, $Pass); // Connects and selects the Table for authentication mysql_select_db("login_ums", $con); // Holding form username and password in variables for processing $varUsr = $_POST['formUsr']; $varPass = $_POST['formPass']; // Store encrypted key "password" in variable $tmp = sha1($varPass); // Set encrypted password to a variable to hold for the remainder of the script ------ May not need due to $tmp variable already holding the pass $varPass = $tmp; $testAcct = mysql_query("SELECT * FROM `login` WHERE Pass = '$varPass'"); $MemStatusTMP = mysql_query("SELECT MemStat FROM `login` WHERE Pass = '$varPass'") or die(mysql_error()); $MemStatus = mysql_fetch_assoc($MemStatusTMP); $Status = $MemStatus[MemStat]; if ($Status = "NoConf") { <---------- This is my test. header('Location: http://www.thegayestcommunityever.com/dev/index.php?section=noconf'); } If (mysql_num_rows($testAcct)){ //include('setstatus.php'); include('activity.php'); //Set user cookies $Time = time() + 7200; $Domain = ".thegayestcommunityever.com"; setcookie("Login", $Time, time()+604800, "/", ".thegayestcommunityever.com"); setcookie("Usr", $varUsr, time()+604800, "/", ".thegayestcommunityever.com"); //Now forward the user to the members section header ('Location: http://www.thegayestcommunityever.com/dev/index.php?section=membershome'); } else { include('AccessDenied.php'); mysql_close($con); } ?> When I echo the contents of $Status it gives me NoConf however the test does not work, and I am unsure if this is due to the fact that I do not have the if statement setup properly or if it is because I am not running the mysql querry propperly. Any help would be greatly appreciated. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/154123-solved-trying-to-set-a-the-contents-of-a-column-in-a-record-to-a-variable-to-test/ Share on other sites More sharing options...
Mchl Posted April 14, 2009 Share Posted April 14, 2009 change it to if ($Status == "NoConf") { notice double = == is for comparisons = is for assigning a value Quote Link to comment https://forums.phpfreaks.com/topic/154123-solved-trying-to-set-a-the-contents-of-a-column-in-a-record-to-a-variable-to-test/#findComment-810185 Share on other sites More sharing options...
TGWSE_GY Posted April 14, 2009 Author Share Posted April 14, 2009 Well it seems to just be skipping over the if ($Status == "NoConf") { Because I know that the value in $Status is NoConf so what else could be wrong been mulling over this for about an hour and cant see where the issue is. Here is the new code <?php /* @author George Young @copyright 2008 This script is ment for a high security login system using advance algorythmic verification. */ // Call database connection info include('config.php'); // Setting variable $con to hold the login information for the mysql server $con = mysql_connect($Host, $Login, $Pass); // Connects and selects the Table for authentication mysql_select_db("login_ums", $con); // Holding form username and password in variables for processing $varUsr = $_POST['formUsr']; $varPass = $_POST['formPass']; // Store encrypted key "password" in variable $tmp = sha1($varPass); // Set encrypted password to a variable to hold for the remainder of the script ------ May not need due to $tmp variable already holding the pass $varPass = $tmp; $testAcct = mysql_query("SELECT * FROM `login` WHERE Pass = '$varPass'"); $MemStatusTMP = mysql_query("SELECT MemStat FROM `login` WHERE Pass = '$varPass'") or die(mysql_error()); $MemStatus = mysql_fetch_assoc($MemStatusTMP); $Status = $MemStatus[MemStat]; if ($Status == "NoConf") { <------- This is what it appears to be skipping header('Location: http://www.thegayestcommunityever.com/dev/index.php?section=noconf'); } If (mysql_num_rows($testAcct)){ //include('setstatus.php'); include('activity.php'); //Set user cookies $Time = time() + 7200; $Domain = ".thegayestcommunityever.com"; setcookie("Login", $Time, time()+604800, "/", ".thegayestcommunityever.com"); setcookie("Usr", $varUsr, time()+604800, "/", ".thegayestcommunityever.com"); //Now forward the user to the members section header ('Location: http://www.thegayestcommunityever.com/dev/index.php?section=membershome'); } else { include('AccessDenied.php'); mysql_close($con); } ?> Thanks again for the help guys. Quote Link to comment https://forums.phpfreaks.com/topic/154123-solved-trying-to-set-a-the-contents-of-a-column-in-a-record-to-a-variable-to-test/#findComment-810256 Share on other sites More sharing options...
xtopolis Posted April 15, 2009 Share Posted April 15, 2009 echo $Status = $MemStatus[MemStat]; and make sure it gives an expected value Without being able to access your database, it seems that the program will behave as expected when $Status == "NoConf" or not. (also, at the top i think you want to say "advanced" rather than advance, which makes no sense) Quote Link to comment https://forums.phpfreaks.com/topic/154123-solved-trying-to-set-a-the-contents-of-a-column-in-a-record-to-a-variable-to-test/#findComment-810305 Share on other sites More sharing options...
TGWSE_GY Posted April 15, 2009 Author Share Posted April 15, 2009 echoing $Status does return the correct value of NoConf, however the if statement is being skipped and the line header ('Location: http://www.thegayestcommunityever.com/dev/index.php?section=membershome'); is being excuted. Which it shouldn't it should be forwarding them to header('Location: http://www.thegayestcommunityever.com/dev/index.php?section=noconf'); . There is no reason why it shouldn't be working. Any ideas would be great. Thanks guys. Quote Link to comment https://forums.phpfreaks.com/topic/154123-solved-trying-to-set-a-the-contents-of-a-column-in-a-record-to-a-variable-to-test/#findComment-810321 Share on other sites More sharing options...
xtopolis Posted April 15, 2009 Share Posted April 15, 2009 It should work. You can debug by doing the following: $Status = "NoConf"; echo "status = $Status"; if ($Status == "NoConf") { die("I made it."); header('Location: http://www.thegayestcommunityever.com/dev/index.php?section=noconf'); } die("Somehow I skipped the if statement"); I tested in this manner and it seemed to produce the right results.. I'm leaning towards $Status = $MemStatus[MemStat]; not being an exact match to "NoConf". Quote Link to comment https://forums.phpfreaks.com/topic/154123-solved-trying-to-set-a-the-contents-of-a-column-in-a-record-to-a-variable-to-test/#findComment-810329 Share on other sites More sharing options...
fenway Posted April 15, 2009 Share Posted April 15, 2009 If this isn't resolved soon, I'll move it to the appropriate forum. Quote Link to comment https://forums.phpfreaks.com/topic/154123-solved-trying-to-set-a-the-contents-of-a-column-in-a-record-to-a-variable-to-test/#findComment-810604 Share on other sites More sharing options...
TGWSE_GY Posted April 15, 2009 Author Share Posted April 15, 2009 Thanks xtoplis, it worked like a charm. Sorry fenway, this started out as a mysql problem. Thanks again for the help guys. Quote Link to comment https://forums.phpfreaks.com/topic/154123-solved-trying-to-set-a-the-contents-of-a-column-in-a-record-to-a-variable-to-test/#findComment-810631 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.