contra10 Posted February 22, 2009 Share Posted February 22, 2009 i'm trying to check if my user has entered the same answer as the answer for security question <?php if (isset($_POST['submit'])) { mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("registration") or die(mysql_error()); //This makes sure they did not leave any fields blank if (!$_POST['a'] | !$_POST['pass'] | !$_POST['pass2']) { die('You did not complete all of the required fields'); } // this makes sure both passwords entered match if ($_POST['a'] != $secreta) { die("Your answer did not match. Please <a href='http://localhost/validation/renew.php?id=$ida'>try again! </a> "); } // this makes sure both passwords entered match if ($_POST['pass'] != $_POST['pass2']) { die('Your passwords did not match. '); } // here we encrypt the password and add slashes if needed $_POST['pass'] = encrypt($_POST['pass']); if (!get_magic_quotes_gpc()) { $_POST['pass'] = addslashes($_POST['pass']); $_POST['username'] = addslashes($_POST['username']); } $pass = mysql_real_escape_string($_POST['pass']); // now we insert it into the database $insert = "UPDATE `users` SET `password` = '$pass' WHERE `username`='$username'"; $add_update = mysql_query($insert); ?> You can now <a href="http://localhost/">login</a> <?php } else { ?> You are almost finish renewing your password<br> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> Please answer your question?<br><?php echo "$secretq $secreta";?><br> Answer:<br> <input type="a" name="a" maxlength="60" STYLE="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;"><br> Username:<br> <input type="text" name="username" maxlength="60" STYLE="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;"><br> New Password:<br> <input type="password" name="pass" maxlength="10" STYLE="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;"><br> Confirm Password:<br> <input type="password" name="pass2" maxlength="10" STYLE="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;"><br> <input type="submit" name="submit" value="Update"/> </form> <?php } ?> i keep getting the die statement at this point <>php // this makes sure both passwords entered match if ($_POST['a'] != $secreta) { die("Your answer did not match. Please <a href='http://localhost/validation/renew.php?id=$ida'>try again! </a> "); } ?> but i did the query and its getting answer and what i enter in the form is the same Quote Link to comment Share on other sites More sharing options...
only one Posted February 22, 2009 Share Posted February 22, 2009 You might need to put quotations around your variable in that if statement. if ($_POST['a'] != "$secreta") { die("Your answer did not match. Please <a href='http://localhost/validation/renew.php?id=$ida'>try again! </a> "); } Quote Link to comment Share on other sites More sharing options...
contra10 Posted February 22, 2009 Author Share Posted February 22, 2009 <?php // this makes sure both passwords entered match if ($_POST['a'] != "$secreta") { die("Your answer did not match. Please <a href='http://localhost/validation/renew.php?id=$id'>try again! </a> "); } ?> still didn't work 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.